<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Heck's  Blog]]></title> 
<link>https://www.heckjj.com/index.php</link> 
<description><![CDATA[一瞬间的决定，往往可以改变很多，事实上，让自己成功的往往不是知识，是精神！ 如果你总是为自己找借口，那只好让成功推迟。执行力，今天！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Heck's  Blog]]></copyright>
<item>
<link>https://www.heckjj.com/post//</link>
<title><![CDATA[解决Spring MVC用AOP处理事务不起作用的问题]]></title> 
<author>Heck &lt;@hecks.tk&gt;</author>
<category><![CDATA[学习心得]]></category>
<pubDate>Sat, 01 Nov 2014 05:01:12 +0000</pubDate> 
<guid>https://www.heckjj.com/post//</guid> 
<description>
<![CDATA[ 
	Spring MVC 3.2.11 + Spring 3.2.11 + Mybatis3.23<br/><br/>1、Spring MVC 和 Spring 整合的时候，SpringMVC的spring-servlet.xml文件中 配置扫描包，不要包含 service的注解，Spring的applicationContext.xml文件中 配置扫描包时，不要包含controller的注解，如下所示：<br/><br/>SpringMVC的spring-servlet.xmll配置：<br/><br/>&lt;context:component-scan base-package=&quot;tk.hecks&quot;&gt;<br/><br/>&nbsp;&nbsp;&lt;context:exclude-filter type=&quot;annotation&quot; expression=&quot;org.springframework.stereotype.Service&quot;/&gt;<br/><br/>&lt;/context:component-scan&gt;<br/><br/>Spring MVC启动时的配置文件，包含组件扫描、url映射以及设置freemarker参数，让spring不扫描带有@Service注解的类。<br/><br/>为什么要这样设置？因为spring-servlet.xmll与applicationContext.xml不是同时加载，如果不进行这样的设置，那么，spring就会将所有带@Service注解的类都扫描到容器中，等到加载applicationContext.xml的时候，会因为容器已经存在Service类，使得cglib将不对Service进行代理，直接导致的结果就是在applicationContext 中的事务配置不起作用，发生异常时，无法对数据进行回滚。以上就是原因所在。<br/><br/>同样的在Spring的xml配置如下：<br/><br/>&lt;context:component-scan base-package=&quot;tk.hecks&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/><br/> &lt;context:exclude-filter type=&quot;annotation&quot; expression=&quot;org.springframework.stereotype.Controller&quot;/&gt;<br/><br/>&lt;/context:component-scan&gt;<br/><br/>扫描包路径，不扫描带有@Controller注解的类。因为这些类已经随容器启动时，在spring-servlet.xml中扫描过一遍了。<br/>Tags - <a href="https://www.heckjj.com/tags/spring/" rel="tag">spring</a> , <a href="https://www.heckjj.com/tags/mvc/" rel="tag">mvc</a> , <a href="https://www.heckjj.com/tags/aop/" rel="tag">aop</a> , <a href="https://www.heckjj.com/tags/freemarker/" rel="tag">freemarker</a> , <a href="https://www.heckjj.com/tags/xml/" rel="tag">xml</a>
]]>
</description>
</item><item>
<link>https://www.heckjj.com/post//#blogcomment</link>
<title><![CDATA[[评论] 解决Spring MVC用AOP处理事务不起作用的问题]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://www.heckjj.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>