console控制台
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building crm_management 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) > compile @ crm_management >>>
[WARNING] The POM for com.oracle:ojdbc6:jar:11.2.0.1.0 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ crm_management ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ crm_management ---
[INFO] No sources to compile
[INFO]
[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) < compile @ crm_management <<<
[INFO]
[INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ crm_management ---
[INFO] Running war on http://localhost:9002/crm_management
[INFO] Using existing Tomcat server configuration at D:\eclipse\develop\SpringTools\Bos2.0\Bos2.0_teach\crm_management\target\tomcat
七月 21, 2017 10:20:20 上午 org.apache.catalina.startup.Embedded start
信息: Starting tomcat server
七月 21, 2017 10:20:20 上午 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.29
七月 21, 2017 10:20:20 上午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
10:20:20,896 INFO ContextLoader:285 - Root WebApplicationContext: initialization started
10:20:21,018 INFO XmlWebApplicationContext:510 - Refreshing Root WebApplicationContext: startup date [Fri Jul 21 10:20:21 CST 2017]; root of context hierarchy
10:20:21,064 INFO XmlBeanDefinitionReader:317 - Loading XML bean definitions from class path resource [applicationContext.xml]
10:20:21,462 INFO PropertySourcesPlaceholderConfigurer:172 - Loading properties file from class path resource [config.properties]
10:20:21,474 INFO AutowiredAnnotationBeanPostProcessor:153 - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
10:20:21,538 INFO MLog:80 - MLog clients using log4j logging.
10:20:21,759 INFO C3P0Registry:204 - Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
10:20:21,907 INFO LocalContainerEntityManagerFactoryBean:339 - Building JPA container EntityManagerFactory for persistence unit 'default'
10:20:21,945 INFO LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [
name: default
...]
10:20:22,062 INFO Version:37 - HHH000412: Hibernate Core {5.0.1.Final}
10:20:22,064 INFO Environment:213 - HHH000206: hibernate.properties not found
10:20:22,066 INFO Environment:317 - HHH000021: Bytecode provider name : javassist
10:20:22,134 INFO Version:66 - HCANN000001: Hibernate Commons Annotations {5.0.0.Final}
10:20:22,328 INFO AbstractPoolBackedDataSource:462 - Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge5om9prgcbeje4phus|1386313f, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> oracle.jdbc.driver.OracleDriver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge5om9prgcbeje4phus|1386313f, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:oracle:thin:@192.168.80.10:1521:orcl, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
10:20:23,209 INFO Dialect:154 - HHH000400: Using dialect: org.hibernate.dialect.Oracle10gDialect
10:20:23,311 INFO LobCreatorBuilderImpl:124 - HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
10:20:23,550 INFO SchemaUpdate:101 - HHH000228: Running hbm2ddl schema update
10:20:23,802 INFO ContextLoader:325 - Root WebApplicationContext: initialization completed in 2904 ms
七月 21, 2017 10:20:23 上午 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-9002
七月 21, 2017 10:20:23 上午 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-9002]
applicationContext.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<!-- 扫描 @Server @Controller @Repository -->
<context:component-scan base-package="cn.itcast"/>
<!-- 加载properties文件 -->
<context:property-placeholder location="classpath:config.properties" />
<!-- 配置数据库连接池 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${jdbc.driver}"/>
<property name="jdbcUrl" value="${jdbc.url}"/>
<property name="user" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<!--整合JPA -->
<!-- 整合JPA配置 -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="cn.itcast.bos.domain" />
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="database" value="ORACLE" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.query.substitutions" value="true 1, false 0" />
<entry key="hibernate.default_batch_fetch_size" value="16" />
<entry key="hibernate.max_fetch_depth" value="2" />
<entry key="hibernate.generate_statistics" value="true" />
<entry key="hibernate.bytecode.use_reflection_optimizer"
value="true" />
<entry key="hibernate.cache.use_second_level_cache" value="false" />
<entry key="hibernate.cache.use_query_cache" value="false" />
</map>
</property>
</bean>
<!-- JPA事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- 注解管理事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!--整合spring data jpa -->
<jpa:repositories base-package="cn.itcast.bos.dao"/>
</beans>
Customer Domain实体类
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "T_CUSTOMER")
public class Customer {
@Id
@GeneratedValue()
@Column(name = "C_ID")
private Integer id; // 主键id
@Column(name = "C_USERNAME")
private String username; // 用户名
@Column(name = "C_PASSWORD")
private String password; // 密码
@Column(name = "C_TYPE")
private Integer type; // 类型 设置1 绑定邮箱
@Column(name = "C_BRITHDAY")
@Temporal(TemporalType.DATE)
private Date birthday; // 生日
@Column(name = "C_SEX")
private Integer sex; // 性别 1男 2女
@Column(name = "C_TELEPHONE")
private String telephone; // 手机
@Column(name = "C_COMPANY")
private String company; // 公司
@Column(name = "C_DEPARTMENT")
private String department; // 部门
@Column(name = "C_POSITION")
private String position; // 职位
@Column(name = "C_ADDRESS")
private String address; // 地址
@Column(name = "C_MOBILEPHONE")
private String mobilePhone; // 座机
@Column(name = "C_EMAIL")
private String email; // 邮箱
@Column(name = "C_Fixed_AREA_ID")
private String fixedAreaId; // 定区编码
get/set方法太多,没有贴出来,自动生成的,应该没有问题.
4 个解决方案
#1
Hibernate 还可以t自动建表? 一般都是提前把表建好,应用程序都是直接 DML 就可以了
#2
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="cn.itcast.bos.domain" />
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="database" value="ORACLE" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.query.substitutions" value="true 1, false 0" />
<entry key="hibernate.default_batch_fetch_size" value="16" />
<entry key="hibernate.max_fetch_depth" value="2" />
<entry key="hibernate.generate_statistics" value="true" />
<entry key="hibernate.bytecode.use_reflection_optimizer"
value="true" />
<entry key="hibernate.cache.use_second_level_cache" value="false" />
<entry key="hibernate.cache.use_query_cache" value="false" />
</map>
</property>
</bean>
在applicationContext.xml配置文件中配置以上信息,.,
不同的数据的建表属性配置是不同的.Oracle是<property name="generateDdl" value="true" />
mysql的属性是update
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="cn.itcast.bos.domain" />
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="database" value="ORACLE" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.query.substitutions" value="true 1, false 0" />
<entry key="hibernate.default_batch_fetch_size" value="16" />
<entry key="hibernate.max_fetch_depth" value="2" />
<entry key="hibernate.generate_statistics" value="true" />
<entry key="hibernate.bytecode.use_reflection_optimizer"
value="true" />
<entry key="hibernate.cache.use_second_level_cache" value="false" />
<entry key="hibernate.cache.use_query_cache" value="false" />
</map>
</property>
</bean>
在applicationContext.xml配置文件中配置以上信息,.,
不同的数据的建表属性配置是不同的.Oracle是<property name="generateDdl" value="true" />
mysql的属性是update
#3
已经解决了..谢谢了..连接Oracle的时候,Oracle的用户属性config.properties中,多写了一个空格,多写了一个空格,多一个空格,一个空格.
user和password的后面多了一个空格.
贴config.properties属性
# oracle jdbc properties
jdbc.url = jdbc:oracle:thin:@192.168.80.10:1521:orcl
jdbc.driver= oracle.jdbc.driver.OracleDriver
jdbc.user = bos
jdbc.password = bos
user和password的后面多了一个空格.
贴config.properties属性
# oracle jdbc properties
jdbc.url = jdbc:oracle:thin:@192.168.80.10:1521:orcl
jdbc.driver= oracle.jdbc.driver.OracleDriver
jdbc.user = bos
jdbc.password = bos
#4
检查配置文件,注意细节,应该是propertity链接数据库是的user和password有问题
#1
Hibernate 还可以t自动建表? 一般都是提前把表建好,应用程序都是直接 DML 就可以了
#2
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="cn.itcast.bos.domain" />
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="database" value="ORACLE" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.query.substitutions" value="true 1, false 0" />
<entry key="hibernate.default_batch_fetch_size" value="16" />
<entry key="hibernate.max_fetch_depth" value="2" />
<entry key="hibernate.generate_statistics" value="true" />
<entry key="hibernate.bytecode.use_reflection_optimizer"
value="true" />
<entry key="hibernate.cache.use_second_level_cache" value="false" />
<entry key="hibernate.cache.use_query_cache" value="false" />
</map>
</property>
</bean>
在applicationContext.xml配置文件中配置以上信息,.,
不同的数据的建表属性配置是不同的.Oracle是<property name="generateDdl" value="true" />
mysql的属性是update
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="cn.itcast.bos.domain" />
<property name="persistenceProvider">
<bean class="org.hibernate.jpa.HibernatePersistenceProvider" />
</property>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="generateDdl" value="true" />
<property name="database" value="ORACLE" />
<property name="databasePlatform" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.query.substitutions" value="true 1, false 0" />
<entry key="hibernate.default_batch_fetch_size" value="16" />
<entry key="hibernate.max_fetch_depth" value="2" />
<entry key="hibernate.generate_statistics" value="true" />
<entry key="hibernate.bytecode.use_reflection_optimizer"
value="true" />
<entry key="hibernate.cache.use_second_level_cache" value="false" />
<entry key="hibernate.cache.use_query_cache" value="false" />
</map>
</property>
</bean>
在applicationContext.xml配置文件中配置以上信息,.,
不同的数据的建表属性配置是不同的.Oracle是<property name="generateDdl" value="true" />
mysql的属性是update
#3
已经解决了..谢谢了..连接Oracle的时候,Oracle的用户属性config.properties中,多写了一个空格,多写了一个空格,多一个空格,一个空格.
user和password的后面多了一个空格.
贴config.properties属性
# oracle jdbc properties
jdbc.url = jdbc:oracle:thin:@192.168.80.10:1521:orcl
jdbc.driver= oracle.jdbc.driver.OracleDriver
jdbc.user = bos
jdbc.password = bos
user和password的后面多了一个空格.
贴config.properties属性
# oracle jdbc properties
jdbc.url = jdbc:oracle:thin:@192.168.80.10:1521:orcl
jdbc.driver= oracle.jdbc.driver.OracleDriver
jdbc.user = bos
jdbc.password = bos
#4
检查配置文件,注意细节,应该是propertity链接数据库是的user和password有问题