首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

SpringMVC JPA 事务,数据库保存操作没有错误但数据保存不成功

2013-03-16 
SpringMVC JPA 事务,数据库保存操作没有异常但数据保存不成功? SpringMVC JPA 事务,数据库保存操作没有异

SpringMVC JPA 事务,数据库保存操作没有异常但数据保存不成功

? SpringMVC JPA 事务,数据库保存操作没有异常但数据保存不成功

?

?? 在主容器中(applicationContext.xml),将Controller的注解排除掉

?

<context:component-scan base-package="net.cloudun">  <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /></context:component-scan> 

?

?? 而在springMVC配置文件(xx-servlet-context.xml)中将Service注解给去掉

?

<context:component-scan base-package="net.cloudsun">  <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />  <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" /></context:component-scan> 

?

因 为spring的context是父子容器,所以会产生冲突,Controller会先进行扫描装配,而此时的Service还没有进行事务的 增强处理,得到的将是原样的Service(没有经过事务加强处理,故而没有事务处理能力) ,最后才是applicationContext.xml中的扫描配置进行事务处理。

?

?

热点排行