发现spring和mybatis集成,如果操作数据库出现多次异常,导致在请求操作数据库会出现:事务不被spring管理的问题。
解决方法在springmvc扫描controller和service的时候,要把带有@Controller和@Service的类进行过滤掉。
配置如下:
<context:component-scan base-package="com.crb.controller,com.crb.serviceImpl">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
想请教大家为什么会出现不被管理问题。