我在网上找的整合代码 我试着自己整合了一下 但是总是报错
具体错误如下:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionInterceptor#0': Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [D:\devs\service\tomcat6_jdk16\webapps\Hitman\WEB-INF\classes\config\applicationContext-common1.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [D:\devs\service\tomcat6_jdk16\webapps\Hitman\WEB-INF\classes\config\applicationContext-common1.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'hibernate.hbm2ddl.auto' of bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Nested property in path 'hibernate.hbm2ddl.auto' does not exist; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'hibernate' of bean class [org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean]: Bean property 'hibernate' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
请高手帮忙解决谢谢

解决方案 »

  1.   

    sessionFactory这个bean初始化错误,可能的原因要么是缺jar包,要么是配置错误,建议楼主写个main方法类,手动控制spring读取配置文件的步骤,有时能看到更多更直观的错误信息。
      

  2.   

    应该是导全了啊 我是从springside里面倒进来的包 应该没问题
      

  3.   

    sessionFactory的定义错误,不能识别hibernate属性,看看你的配置文件
      

  4.   

    集成Hibernate出错。仅这些消息不够,最好贴出xml配置文件和jar包的目录。
      

  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:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="   
                http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd   
                http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-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/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd   
                http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="ignoreResourceNotFound" value="true" />
    <property name="locations">
    <list>
    <value>/WEB-INF/config/jdbc.properties</value>
    </list>
    </property>
    </bean>

    <!-- c3p0 datasource  -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"           
            destroy-method="close">          
        <property name="driverClass" value="${jdbc.driverClass}"/>
        <property name="jdbcUrl" value="${jdbc.jdbcUrl}"/>
        <property name="user" value="${jdbc.user}"/> 
        <property name="password" value="${jdbc.password}"/>
        <property name="initialPoolSize" value="${jdbc.initialPoolSize}" />
    <property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
    </bean>

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    ${hibernate.dialect}
    </prop>
    <prop key="hibernate.show_sql">true</prop>
    <!--   
    <prop  
    key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop>  
    <prop key="hibernate.cache.use_second_level_cache">true</prop>  
    <prop key="hibernate.cache.use_query_cache">true</prop> <prop  
    key="hibernate.cache.use_structured_entries">true</prop> <prop  
    key="hibernate.connection.release_mode">auto</prop>  
    -->
    </props>
    </property>
    <property name="packagesToScan"
    value="com.mchz.common.domain.persistence" />
    </bean> <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    </beans>
      

  6.   

    Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file 
    事务配置错了~引用不正确
      

  7.   

    web.xml文件用listenter加载吗?
    可以改成servlet来试一下
      

  8.   

    怎么没看到hibernate 映射文件啊.
    <bean id="sessionFactory" 
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
    <property name="dataSource" ref="dataSource" /> 
    <property name="hibernateProperties"> 
    <props> 
    <prop key="hibernate.dialect"> 
    ${hibernate.dialect} 
    </prop> 
    <prop key="hibernate.show_sql">true </prop> 
    <!--  
    <prop  
    key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider </prop>  
    <prop key="hibernate.cache.use_second_level_cache">true </prop>  
    <prop key="hibernate.cache.use_query_cache">true </prop> <prop  
    key="hibernate.cache.use_structured_entries">true </prop> <prop  
    key="hibernate.connection.release_mode">auto </prop>  
    --> 
    </props> 
    </property> 
    <property name="packagesToScan" 
    value="com.mchz.common.domain.persistence" /> 
    </bean>
      

  9.   

    问题解决了 是JAR包得问题 重新找个导进来就没事了 具体是哪个JAR的问题不知道 真愁人
    结贴了 谢谢各位!