<!-- 自动扫描组件,这里要把controler下面的 controller去除,他们是在spring3-servlet.xml中配置的,如果不去除会影响事务管理的。 --> <context:component-scan base-package=\"com.sence\"> <context:exclude-filter type=\"annotation\" expression=\"org.springframework.stereotype.Controller\" /> .</context:component-scan> <!-- 自动扫描组件,这里要把controler下面的 controller去除,他们是在spring3-servlet.xml中配置的,如果不去除会影响事务管理的。 --> <context:component-scan base-package=\"com.sence\"> <context:exclude-filter type=\"annotation\" expression=\"org.springframework.stereotype.Controller\" /> </context:component-scan>
<!-- 扫描所有的controller 但是不扫描service--> <context:component-scan base-package=\"com.sence\"> <context:include-filter type=\"annotation\" expression=\"org.springframework.stereotype.Controller\" /> <context:exclude-filter type=\"annotation\" expression=\"org.springframework.stereotype.Service\" /> </context:component-scan> <!-- 扫描所有的controller 但是不扫描service--> <context:component-scan base-package=\"com.sence\"> <context:include-filter type=\"annotation\" expression=\"org.springframework.stereotype.Controller\" /> <context:exclude-filter type=\"annotation\" expression=\"org.springframework.stereotype.Service\" /> </context:component-scan>
<!-- transaction manager, use DataSourceTransactionManager --> <bean id=\"txManager\" class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\"> <property name=\"dataSource\" ref=\"dataSource\" /> </bean> <!-- spring declarative transaction management --> <aop:config> <aop:pointcut id=\"fooServiceMethods\" expression=\"execution(* com.sence.*.service.impl.*.*(..))\"/> <aop:advisor advice-ref=\"txAdvice\" pointcut-ref=\"fooServiceMethods\"/> </aop:config> <tx:advice id=\"txAdvice\" transaction-manager=\"txManager\"> <tx:attributes> <tx:method name=\"find*\" read-only=\"true\"/> <tx:method name=\"load*\" read-only=\"true\"/> <tx:method name=\"*\" rollback-for=\"CustomException\"/> </tx:attributes> </tx:advice> <!-- transaction manager, use DataSourceTransactionManager --> <bean id=\"txManager\" class=\"org.springframework.jdbc.datasource.DataSourceTransactionManager\"> <property name=\"dataSource\" ref=\"dataSource\" /> </bean> <!-- spring declarative transaction management --> <aop:config> <aop:pointcut id=\"fooServiceMethods\" expression=\"execution(* com.sence.*.service.impl.*.*(..))\"/> <aop:advisor advice-ref=\"txAdvice\" pointcut-ref=\"fooServiceMethods\"/> </aop:config> <tx:advice id=\"txAdvice\" transaction-manager=\"txManager\"> <tx:attributes> <tx:method name=\"find*\" read-only=\"true\"/> <tx:method name=\"load*\" read-only=\"true\"/> <tx:method name=\"*\" rollback-for=\"CustomException\"/> </tx:attributes> </tx:advice>
本文地址:https://www.stayed.cn/item/24834
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我