配置文件:
<?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: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/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- 配置SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 使用本地的hibernate.cfg.xml配置文件,这样清晰一点 -->
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<bean id="userDao" class="com.singleusers.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory">
</property>
</bean>
<bean id="userService" class="com.singleusers.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean> <bean id="addUserAction" class="com.singleusers.adduser.action.AddUserAction">
<property name="service" ref="userService"></property>
</bean> <!-- -->
<!-- 配置事物管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- AOP,那些包下面的类需要使用事物管理器 -->
<aop:config>
<aop:pointcut id="servieMethod"
expression="execution(* com.singleusers.service.*.*(..))" />
<!-- 如果满足servieMethod这个切入点就去 参考事物传播性配置的txAdvice建议-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="servieMethod" />
</aop:config> <!-- 事物传播性配置 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--
propagation="REQUIRED" 当前有事物则加入,否则新建一个事物,read-only="true" 事物是否只读
-->
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
</beans>userService哪错了???急求解
<?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: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/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- 配置SessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 使用本地的hibernate.cfg.xml配置文件,这样清晰一点 -->
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<bean id="userDao" class="com.singleusers.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory">
</property>
</bean>
<bean id="userService" class="com.singleusers.service.impl.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean> <bean id="addUserAction" class="com.singleusers.adduser.action.AddUserAction">
<property name="service" ref="userService"></property>
</bean> <!-- -->
<!-- 配置事物管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- AOP,那些包下面的类需要使用事物管理器 -->
<aop:config>
<aop:pointcut id="servieMethod"
expression="execution(* com.singleusers.service.*.*(..))" />
<!-- 如果满足servieMethod这个切入点就去 参考事物传播性配置的txAdvice建议-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="servieMethod" />
</aop:config> <!-- 事物传播性配置 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--
propagation="REQUIRED" 当前有事物则加入,否则新建一个事物,read-only="true" 事物是否只读
-->
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="del*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
</beans>userService哪错了???急求解
TransactionInterceptor是 org.aopalliance.aop.Advice 的一个实现,可能是Jar包的冲突。
到jar包中去查看。
我的问题是: aopalliance-1.0.jar 和 aopalliance-alpha1.jar之间的冲突。
将后者去掉,再运行就OK了。
这个异常表明引用的类型不对估计是引用了aopalliance-alpha1.jar包中的Advice了。。谢谢分享...LZ