在主容器中(applicationContext.xml),将Controller的注解排除掉
<context:component-scan base-package="com.microdata">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
</context:component-scan>
在SpringMVC.xml中,将Service注解排除掉
<context:component-scan base-package="com.microdata">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>
要回滚事务,还需要的抛出运行时异常,
或者在catch 语句块中 加上 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();