我用Spring控制Hibernate,但无法自动生成数据库,这是日志,求解!

时间:2021-12-28 23:18:18

INFO - hibernate.properties not found
INFO - Bytecode provider name : cglib
INFO - using JDK 1.4 java.sql.Timestamp handling
INFO - Mapping class: com.xiong.myhrs.model.Application -> Application
INFO - Mapping class: com.xiong.myhrs.model.Attend -> Attend
INFO - Mapping class: com.xiong.myhrs.model.AttendType -> type
INFO - Mapping class: com.xiong.myhrs.model.CheckBack -> CheckBack
INFO - Mapping class: com.xiong.myhrs.model.Employee -> Employee
INFO - Mapping joined-subclass: com.xiong.myhrs.model.Manager -> Manager
INFO - Mapping class: com.xiong.myhrs.model.Payment -> Payment
INFO - Mapping collection: com.xiong.myhrs.model.Attend.applications -> Application
INFO - Mapping collection: com.xiong.myhrs.model.Employee.attends -> Attend
INFO - Mapping collection: com.xiong.myhrs.model.Employee.payments -> Payment
INFO - Mapping collection: com.xiong.myhrs.model.Manager.checkBacks -> CheckBack
INFO - Mapping collection: com.xiong.myhrs.model.Manager.employees -> Employee
INFO - Building new Hibernate SessionFactory
INFO - Initializing connection provider: org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider
INFO - 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 -> 1hge4gb8fobfe6d15blfp6|f0b4a3, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge4gb8fobfe6d15blfp6|f0b4a3, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost:3306/myhrs, 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 ]
INFO - RDBMS: MySQL, version: 5.1.53-community
INFO - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.7 ( Revision: ${svn.Revision} )
INFO - Using dialect: org.hibernate.dialect.MySQLDialect
INFO - Transaction strategy: org.springframework.orm.hibernate3.SpringTransactionFactory
INFO - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
INFO - Automatic flush during beforeCompletion(): disabled
INFO - Automatic session close at end of transaction: disabled
INFO - JDBC batch size: 15
INFO - JDBC batch updates for versioned data: disabled
INFO - Scrollable result sets: enabled
INFO - JDBC3 getGeneratedKeys(): enabled
INFO - Connection release mode: auto
INFO - Maximum outer join fetch depth: 2
INFO - Default batch fetch size: 1
INFO - Generate SQL with comments: disabled
INFO - Order SQL updates by primary key: disabled
INFO - Order SQL inserts for batching: disabled
INFO - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
INFO - Using ASTQueryTranslatorFactory
INFO - Query language substitutions: {}
INFO - JPA-QL strict compliance: disabled
INFO - Second-level cache: enabled
INFO - Query cache: enabled
INFO - Cache provider: org.hibernate.cache.EhCacheProvider
INFO - Optimize cache for minimal puts: disabled
INFO - Structured second-level cache entries: disabled
INFO - Query cache factory: org.hibernate.cache.StandardQueryCacheFactory
INFO - Echoing all SQL to stdout
INFO - Statistics: disabled
INFO - Deleted entity synthetic identifier rollback: disabled
INFO - Default entity-mode: pojo
INFO - Named query checking : enabled
INFO - building session factory
WARN - Could not find configuration [com.xiong.myhrs.model.Payment]; using defaults.
WARN - Could not find configuration [com.xiong.myhrs.model.Attend]; using defaults.
WARN - Could not find configuration [com.xiong.myhrs.model.Employee]; using defaults.
WARN - Could not find configuration [com.xiong.myhrs.model.AttendType]; using defaults.
WARN - Could not find configuration [com.xiong.myhrs.model.CheckBack]; using defaults.
WARN - Could not find configuration [com.xiong.myhrs.model.Application]; using defaults.
INFO - Not binding factory to JNDI, no JNDI name configured

INFO - starting update timestamps cache at region: org.hibernate.cache.UpdateTimestampsCache
INFO - starting query cache at region: org.hibernate.cache.StandardQueryCache
INFO - Using DataSource [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 -> 1hge4gb8fobfe6d15blfp6|f0b4a3, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge4gb8fobfe6d15blfp6|f0b4a3, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost:3306/myhrs, 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 ]] of Hibernate SessionFactory for HibernateTransactionManager
INFO - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
INFO - Quartz Scheduler v.1.6.1 created.
INFO - RAMJobStore initialized.
INFO - Quartz scheduler 'QuartzScheduler' initialized from an externally provided properties instance.
INFO - Quartz scheduler version: 1.6.1
INFO - JobFactory set to: org.springframework.scheduling.quartz.AdaptableJobFactory@1ca5df9
INFO - Starting Quartz Scheduler now
INFO - Scheduler QuartzScheduler_$_NON_CLUSTERED started.
INFO - Root WebApplicationContext: initialization completed in 9556 ms
INFO - Parsing configuration file [struts-default.xml]
INFO - Parsing configuration file [struts-plugin.xml]
INFO - Parsing configuration file [struts.xml]
INFO - Initializing Struts-Spring integration...
INFO - Setting autowire strategy to name
INFO - ... initialized Struts-Spring integration successfully

7 个解决方案

#1


第一行信息显示
INFO - hibernate.properties not found
这个提示未找到配置文件

#2


hibenrate的配置文件都没有。。。。

#3


我有.hbm.xml文件,然后在Spring里mapping了,还需要怎么配?

#4


<prop key="hibernate.hbm2ddl.auto">update</prop> 

加这个了么

#5


<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

 

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/myhrs"/>
    <property name="user" value="root"/>
    <property name="password" value="root"/>
  </bean> 
 
  
  
  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
    <list>
       <value>com/xiong/myhrs/model/Application.hbm.xml</value>
       <value>com/xiong/myhrs/model/Attend.hbm.xml</value>
       <value>com/xiong/myhrs/model/AttendType.hbm.xml</value>
       <value>com/xiong/myhrs/model/CheckBack.hbm.xml</value>
       <value>com/xiong/myhrs/model/Employee.hbm.xml</value>
       <value>com/xiong/myhrs/model/Payment.hbm.xml</value>
    </list>
    
    
    </property>
    <property name="hibernateProperties">
     <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.format_sql">true</prop>
      
       
        <prop key="hibernate.cache.use_second_level_cache ">true</prop>
        <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
        <prop key="hibernate.cache.use_query_cache">true</prop>       
    </props>
  </property>
 </bean>

 
 
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="cacheQueries" value="true"/>
 <property name="sessionFactory" ref="sessionFactory"/>
</bean>
 <bean id="daoTemplate"  abstract="true" lazy-init="true">
  <!-- <property name="sessionFactory" ref="sessionFactory"/> -->
<property name="hibernateTemplate" ref="hibernateTemplate"/>
 </bean>
  
 <bean id="paymentDao" class="com.xiong.myhrs.dao.impl.PaymentDaoImpl" parent="daoTemplate"/>
 <bean id="employeeDao" class="com.xiong.myhrs.dao.impl.EmployeeDapImpl" parent="daoTemplate"/>
 <bean id="appDao" class="com.xiong.myhrs.dao.impl.ApplicationDaoImpl" parent="daoTemplate"/>
 <bean id="attendDao" class="com.xiong.myhrs.dao.impl.AttendDaoImpl" parent="daoTemplate"/>
 <bean id="attendTypeDao" class="com.xiong.myhrs.dao.impl.AttendTypeDaoImpl" parent="daoTemplate"/>
 <bean id="checkBackDao" class="com.xiong.myhrs.dao.impl.CheckBackDaoImpl" parent="daoTemplate"/>
 <bean id="managerDao" class="com.xiong.myhrs.dao.impl.ManagerDaoImpl" parent="daoTemplate"/>
 <bean id="empManager" class="com.xiong.myhrs.service.impl.EmpManagerImpl" autowire="byType"/>
 <bean id="manaManager" class="com.xiong.myhrs.service.impl.ManaManagerImpl" autowire="byType"/>

 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
 <property name="sessionFactory" ref="sessionFactory"/>
 </bean>

  <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
    <tx:method name="get*" read-only="true"/>
    <tx:method name="*"/>
  </tx:attributes>
 </tx:advice>
 
 <aop:config>
   <aop:pointcut expression="execution(* com.xiong.myhrs.service.impl.*Impl.*(..))" id="myPointcut"/>
   <aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut"/>
 
 </aop:config> 

 <bean id="cronTriggerPay" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail">
    <bean class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="com.xiong.myhrs.quartz.PayJob"/>
    <property name="jobDataAsMap">
     <map>
      <entry key="empManager" value-ref="empManager"/>
     </map>
    </property>
    </bean>
 </property>
 <property name="cronExpression" value="0 0 2 3 * ? *"/>
 </bean>
 
  <bean id="cronTriggerPunch" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail">
    <bean class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="com.xiong.myhrs.quartz.PunchJob"/>
    <property name="jobDataAsMap">
     <map>
      <entry key="empManager" value-ref="empManager"/>
     </map>
    </property>
    </bean>
 </property>
 <property name="cronExpression" value="0 0 7,12 ? * MON-FRI"/>
 </bean>
 
 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
 <property name="triggers">
    <list>
      <ref local="cronTriggerPay"/>
      <ref local="cronTriggerPunch"/>
    </list>
 </property>
 </bean>
</beans>
这是我的Spring

#6


谢谢了,解决了哈

#7


解决了说个解决方法啊,

#1


第一行信息显示
INFO - hibernate.properties not found
这个提示未找到配置文件

#2


hibenrate的配置文件都没有。。。。

#3


我有.hbm.xml文件,然后在Spring里mapping了,还需要怎么配?

#4


<prop key="hibernate.hbm2ddl.auto">update</prop> 

加这个了么

#5


<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

 

 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="com.mysql.jdbc.Driver"/>
    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/myhrs"/>
    <property name="user" value="root"/>
    <property name="password" value="root"/>
  </bean> 
 
  
  
  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
    <list>
       <value>com/xiong/myhrs/model/Application.hbm.xml</value>
       <value>com/xiong/myhrs/model/Attend.hbm.xml</value>
       <value>com/xiong/myhrs/model/AttendType.hbm.xml</value>
       <value>com/xiong/myhrs/model/CheckBack.hbm.xml</value>
       <value>com/xiong/myhrs/model/Employee.hbm.xml</value>
       <value>com/xiong/myhrs/model/Payment.hbm.xml</value>
    </list>
    
    
    </property>
    <property name="hibernateProperties">
     <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.format_sql">true</prop>
      
       
        <prop key="hibernate.cache.use_second_level_cache ">true</prop>
        <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
        <prop key="hibernate.cache.use_query_cache">true</prop>       
    </props>
  </property>
 </bean>

 
 
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="cacheQueries" value="true"/>
 <property name="sessionFactory" ref="sessionFactory"/>
</bean>
 <bean id="daoTemplate"  abstract="true" lazy-init="true">
  <!-- <property name="sessionFactory" ref="sessionFactory"/> -->
<property name="hibernateTemplate" ref="hibernateTemplate"/>
 </bean>
  
 <bean id="paymentDao" class="com.xiong.myhrs.dao.impl.PaymentDaoImpl" parent="daoTemplate"/>
 <bean id="employeeDao" class="com.xiong.myhrs.dao.impl.EmployeeDapImpl" parent="daoTemplate"/>
 <bean id="appDao" class="com.xiong.myhrs.dao.impl.ApplicationDaoImpl" parent="daoTemplate"/>
 <bean id="attendDao" class="com.xiong.myhrs.dao.impl.AttendDaoImpl" parent="daoTemplate"/>
 <bean id="attendTypeDao" class="com.xiong.myhrs.dao.impl.AttendTypeDaoImpl" parent="daoTemplate"/>
 <bean id="checkBackDao" class="com.xiong.myhrs.dao.impl.CheckBackDaoImpl" parent="daoTemplate"/>
 <bean id="managerDao" class="com.xiong.myhrs.dao.impl.ManagerDaoImpl" parent="daoTemplate"/>
 <bean id="empManager" class="com.xiong.myhrs.service.impl.EmpManagerImpl" autowire="byType"/>
 <bean id="manaManager" class="com.xiong.myhrs.service.impl.ManaManagerImpl" autowire="byType"/>

 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
 <property name="sessionFactory" ref="sessionFactory"/>
 </bean>

  <tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
    <tx:method name="get*" read-only="true"/>
    <tx:method name="*"/>
  </tx:attributes>
 </tx:advice>
 
 <aop:config>
   <aop:pointcut expression="execution(* com.xiong.myhrs.service.impl.*Impl.*(..))" id="myPointcut"/>
   <aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut"/>
 
 </aop:config> 

 <bean id="cronTriggerPay" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail">
    <bean class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="com.xiong.myhrs.quartz.PayJob"/>
    <property name="jobDataAsMap">
     <map>
      <entry key="empManager" value-ref="empManager"/>
     </map>
    </property>
    </bean>
 </property>
 <property name="cronExpression" value="0 0 2 3 * ? *"/>
 </bean>
 
  <bean id="cronTriggerPunch" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail">
    <bean class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="com.xiong.myhrs.quartz.PunchJob"/>
    <property name="jobDataAsMap">
     <map>
      <entry key="empManager" value-ref="empManager"/>
     </map>
    </property>
    </bean>
 </property>
 <property name="cronExpression" value="0 0 7,12 ? * MON-FRI"/>
 </bean>
 
 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
 <property name="triggers">
    <list>
      <ref local="cronTriggerPay"/>
      <ref local="cronTriggerPunch"/>
    </list>
 </property>
 </bean>
</beans>
这是我的Spring

#6


谢谢了,解决了哈

#7


解决了说个解决方法啊,