SpringMVC+Mybatis配置事务,回滚失败。
WEB.XML:<context-param><param-name>contextConfigLocation</param-name><param-value>cla...
WEB.XML:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-jdbc.xml</param-value>
<filter>
<filter-name>characterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Spring-Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring-Servlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
application-springmvc.xml:
<cxt:component-scan base-package="com.gta.xlep">
</cxt:component-scan>
application-jdbc.xml:
<!-- 5. 使用声明式事务 -->
<aop:config>
<aop:advisor pointcut="execution(* com.gta.*.service.*Impl.*(..))"
advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.Exception" />
</tx:attributes>
</tx:advice>
<tx:annotation-driven transaction-manager="transactionManager" />
com.gta.xlep.service.SingleTableServiceImpl
public void saveOrganization(OrganizationVo organization) {} 展开
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-jdbc.xml</param-value>
<filter>
<filter-name>characterEncoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>Spring-Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:application-springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring-Servlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
application-springmvc.xml:
<cxt:component-scan base-package="com.gta.xlep">
</cxt:component-scan>
application-jdbc.xml:
<!-- 5. 使用声明式事务 -->
<aop:config>
<aop:advisor pointcut="execution(* com.gta.*.service.*Impl.*(..))"
advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="save*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.Exception" />
</tx:attributes>
</tx:advice>
<tx:annotation-driven transaction-manager="transactionManager" />
com.gta.xlep.service.SingleTableServiceImpl
public void saveOrganization(OrganizationVo organization) {} 展开
2个回答
展开全部
<context:component-scan base-package="com.ggg.xlep" >
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
jdbc:
<!-- 启动包扫描功能 -->
<cxt:component-scan base-package="com.ggg.xlep">
<cxt:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<cxt
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
jdbc:
<!-- 启动包扫描功能 -->
<cxt:component-scan base-package="com.ggg.xlep">
<cxt:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<cxt
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询