Common reasons why spring declarative things don't work
<!--transaction configuration: Transaction manager-->
<bean id= "TransactionManager"
class= "Org.springframework.orm.hibernate4.HibernateTransactionManager" >
<property name= "Sessionfactory" ref= "Sessionfactory"/>
<property name= "DataSource" ref= "DataSource"/>
</bean>
<aop:aspectj-autoproxy proxy-target-class= "true" expose-proxy= "true"/>
<aop:config>
<aop:advisor pointcut= "Execution (* Com.framework.common. *service*.* (..)) "
advice-ref= "Txadvice"/>
</aop:config>
<tx:advice id= "Txadvice" transaction-manager= "TransactionManager" >
<tx:attributes>
<tx:method name= "save*" propagation= "REQUIRED"
Rollback-for= "Exception"/>
<tx:method name= "update*" propagation= "REQUIRED"
Rollback-for= "Exception"/>
<tx:method name= "delete*" propagation= "REQUIRED"
Rollback-for= "Exception"/>
<tx:method name= "get*" read-only= "true"/>
<tx:method name= "query*" read-only= "true"/>
<tx:method name= "Pagequery" read-only= "true"/>
<tx:method name= "*" propagation= "REQUIRED" rollback-for= "Exception"/>
</tx:attributes>
</tx:advice>
Ps:
1, applicationcontext.xml note Enable <aop:aspectj-autoproxy proxy-target-class= "true" expose-proxy= "true"/>
2, APPLICATIONCONTEXT.XMLL attention expression= "Execution" (* Com.xx.xxx.service ... *(..)) "The right to write
3, if you are using the Spring MVC approach, pay attention to the Applicationcontext-springmvc.xml file <context:component-scan base-package= "com.xx.xxx"/ > May cause your service (at this point not to produce things related to the agent class) ahead of loading, resulting in the configuration of things does not work.
Workaround:
Applicationcontext-springmvc.xml adds the following configuration, declaring that spring MVC is initialized with only scanning controller.
<context:component-scan base-package= "Com.framework" use-default-filters= "false" >
<context:include-filter expression= "Org.springframework.stereotype.Controller" type= "annotation"/>
</context:component-scan>
APPLICATIONCONTEXT.XMLL adds the following configuration, declaring spring initialization without scanning controller.
<context:component-scan base-package= "Com.framework" >
<context:exclude-filter expression= "Org.springframework.stereotype.Controller" type= "annotation"/>
</context:component-scan>