用spring配置一个事务,配置出现问题了,求教

appleYQL 2017-05-02 09:05:00
今天整合个ssm框架,在配置事务时出现这种错误:

配置文件内容如下:
<?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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">

<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" ></property>
</bean>

<tx:advice transaction-manager="transactionManager" >
<tx:attributes>
<tx:method name="delete" propagation="REQUIRED" />
<tx:method name="insert" propagation="REQUIRED" />
<tx:method name="update" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>

<aop:config>
<aop:pointcut expression="execution(* com.ssm.service.Imp.*.*(..))" id="pointcut"/>
<aop:advisor advice-ref="transactionManager" pointcut-ref="pointcut"/>
</aop:config>
</beans>

另外我的数据源是配置在另一个dao文件的:

之前看视频,数据源是可以直接引用的,不知道是不是这里出问题
web.xml的配置如下:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/spring/applicationContext-*.xml
</param-value>
</context-param>
<!-- 启动ioc容器的ServletContextListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

所以想问一下,事务配置那部分为什么会这样报错,第一次遇见,萌新求教
...全文
70 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
李德胜1995 2017-05-02
  • 打赏
  • 举报
回复
引用 2 楼 pany1209 的回复:
给tx:advice加个id属性。。。。在下面的advice-ref="写的id"就可以了
我日。。。。刚发出去就结帖了
李德胜1995 2017-05-02
  • 打赏
  • 举报
回复
给tx:advice加个id属性。。。。在下面的advice-ref="写的id"就可以了
appleYQL 2017-05-02
  • 打赏
  • 举报
回复
知道了,是我粗心了---

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧