org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'org.springframework.transaction.interceptor.TransactionInterceptor#0' is expected to be of type 'org.aopalliance.aop.Advice' but was actually of type 'org.springframework.transa
package com.lzj.Spring_second.test3; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service("bookStoreServiceImpl") public class BookStoreServiceImpl implements BookStoreService { // 自动注入DAO(接口注入) @Autowired private BookStore bookStoreImpl; // 添加事物注解 @Transactional @Override public void purchaseBook(String userName,String bookName) { // 查看购买书的价格 int price = bookStoreImpl.getBookByName(bookName); // 更新库存 bookStoreImpl.updateBookStore(bookName); // 更新客户的钱 bookStoreImpl.updateCustomerMoney(userName, price); } }
一添加@Transactional注解就抛上面的错误,好多人说是动态代理中抛出来的,但是我的Bean都是接口注入的也还是报错,下面是事物的相关配置,哪位大神帮忙看看,多谢!
<!-- 配置自动扫描包 --> <context:component-scan base-package="com.lzj.Spring_second.test3"></context:component-scan> <!-- 引入外部数据 --> <context:property-placeholder location="classpath:com/lzj/Spring_second/test3/config/data.properties"/> <!-- 通过数据源连接数据库 --> <bean id="sqlConnctionDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="user" value="${user}"></property> <property name="password" value="${password}"></property> <property name="driverClass" value="${driverClass}"></property> <property name="jdbcUrl" value="${jdbcUrl}"></property> </bean> <!-- 配置事物管理器 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="sqlConnctionDataSource"></property> </bean> <!-- 启用事物管理器注解 --> <tx:annotation-driven transaction-manager="transactionManager"/>
我是大树
HansonQ
相关分类