java – Spring AOP是否编译时编织或加载时间编织?
我开始使用
Spring AOP进行项目,我对编织有点困惑.我知道Spring AOP依赖于AspectJweaver.jar,但正如文档所说,这不是编织,而只是它使用了这个jar中的一些类.
但我的问题是,如果不使用AspectJ进行编织,Spring AOP是否有自己的编织,是在加载时还是编译时执行? 我的Spring配置XML文件的相关部分是: <context:annotation-config /> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="*" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id="myaop" expression="execution(* my.package.*.*(..))" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="myaop" /> </aop:config> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> 解决方法
http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#aop-introduction-defn
在8.1.1项目编织下,它说:
Spring不像AspectJ那样进行相同类型的加载时编织,但是在代理上工作,如文档的另一部分所述: http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#aop-understanding-aop-proxies 编辑:刚刚看到你的评论,你在这个假设中是正确的.该文档提供了一个相当完整的解释,说明它是如何工作的. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |