【发布时间】:2018-12-29 11:00:44
【问题描述】:
我做了一个javaweb的基础项目,在上面加了spring事务配置,但是没有效果。在此之前,它运行良好。我在网上搜索了很多页面,这些配置和我的一样。
预期结果是什么都不会插入,但插入了一条记录。
请帮我找出问题所在,谢谢
我的serviceimpl路径是:com.lidaning.sys.user.service.UserInfoServiceImpl
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="txPointcut" expression="execution(* com.lidaning.sys.user.service..*.*(..))" />
<aop:advisor pointcut-ref="txPointcut" advice-ref="txAdvice"/>
</aop:config>
@Override
public void insertUser(UserInfo u) {
u.setId("1");
u.setName("lidaning");
u.setPassword("***");
userInfoDao.insertUser(u);
userInfoDao.insertUser(u); //occur exception
}
【问题讨论】:
标签: java transactions