Does Spring AOP do compile time weaving or load time weaving?

我怕爱的太早我们不能终老 提交于 2019-12-03 03:23:52
sheltem

http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#aop-introduction-defn

Under 8.1.1, item weaving, it says:

Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or at runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.

Spring doesn't do the same type of load-time weaving as AspectJ, but works on proxies, as described in another part of the documentation:

http://docs.spring.io/spring/docs/4.0.1.RELEASE/spring-framework-reference/htmlsingle/#aop-understanding-aop-proxies

Edit: Just saw your comment, you are correct in that assumption. The documentation gives a rather complete explanation of how it works exactly. :)

An update who is reading this in 2019 and probably later:

In spring 5.x aspectjweaver.jar was removed as a dependency and there is a need to include it separately if you want to use @AspectJ style annotations (or use Spring Boot for example).

Weaving principles stay the same though - documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!