must be of type [org.aopalliance.aop.Advice]错误问题
我使用的是hibernate4+spring3,练习事务管理,运行程序报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in file [D:\Program-exercise\J2EE\spring_1800_hibernate_transaction\bin\com\service\UserService.class]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Unexpected AOP exception; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'org.springframework.transaction.interceptor.TransactionInterceptor#0' must be of type [org.aopalliance.aop.Advice], but was actually of type [org.springframework.transaction.interceptor.TransactionInterceptor]
网上google了,说什么发现 aopalliance-1.0.jar 和 aopalliance-alpha1.jar 两个包冲突了,去掉后者就行了。
问题是,我压根就没有在引入的jar包里面找到这个上面的这两个jar包的影子,真的不知道怎么解决这个问题,求教,非常感谢。 请详细点,谢谢
--------------------编程问答-------------------- 不知道 --------------------编程问答-------------------- 尚学堂的代码?spring配置bean的配置文件贴上来。 --------------------编程问答--------------------
你好,是尚学堂的代码,bean配置文件是
<?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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com"/>
<!-- 占位符变量对应的值放在jdbc.properties里面 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean>
<!--这里使用占位符来管理和定义连接数据库的信息 -->
<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses"><!-- 表示对哪些类做了注解 -->
<list>
<value>com.model.User</value>
<value>com.model.Log</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
</beans> --------------------编程问答-------------------- 可能是开发工具自动加载的包 --------------------编程问答-------------------- 应该不是,很有可能是jar包冲突,但是真的具体不知道怎么检查是哪两个包冲突 --------------------编程问答-------------------- 没有人来解答吗?
补充:Java , Java EE