org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Can't resolve reference to bean 'transactionInterceptor' while setting property 'transactionInterceptor'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionInterceptor' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Can't resolve reference to bean 'transactionManager' while setting property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionInterceptor' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Can't resolve reference to bean 'transactionManager' while setting property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/Hibernate_Context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
我用的是hibernate3.0,估计是数据库初始化出错,但是我能用工具联上数据库,hibernate配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- ========================= RESOURCE DEFINITIONS ========================= -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" destroy-method="close">
<property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property>
<property name="url"><value>jdbc:mysql://192.168.1.16:3306/scrabble</value></property>
<property name="username"><value>root</value></property>
<property name="password"><value>root</value></property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configurationClass"><value>org.hibernate.cfg.AnnotationConfiguration</value></property>
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="configLocation"><value>/hibernate.cfg.xml</value></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
<property name="dataSource"><ref bean="dataSource"/></property>
</bean>
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/>
<bean class="org.springframework.transaction.interceptor.TransactionAttributeSourceAdvisor">
<property name="transactionInterceptor"><ref bean="transactionInterceptor"/></property>
</bean>
<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="transactionAttributeSource">
<bean class="org.springframework.transaction.annotation.AnnotationTransactionAttributeSource"/>
</property>
</bean>
<!-- ========================= DAO DEFINITIONS ========================= -->
<!--
<bean id="testDao" class="org.steeven.TestDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
-->
<!-- ========================= DAO DEFINITIONS ========================= -->
<!--
<bean id="mitService" class="org.steeven.TestServiceImpl"></bean>
-->
</beans>
4 个解决方案
#1
好象是找不到bean吧!!我也不熟spring框架呢,顶下!!
#2
检查一次,spring需要的jar包是否已经加到classes下面了。
#3
#4
XML文件检查一下,是否有写错?用XMLSpy检查一下
#1
好象是找不到bean吧!!我也不熟spring框架呢,顶下!!
#2
检查一次,spring需要的jar包是否已经加到classes下面了。
#3
#4
XML文件检查一下,是否有写错?用XMLSpy检查一下