How does AspectJ's load-time-weaver find META-INF\aop.xml?

点点圈 提交于 2019-12-21 17:50:07

问题


I am attempting to use load-time-weaving to tie perf4j into a program, but it does not seem to be finding aop.xml in my classpath. Either that or it is not weaving the aspect because it is not finding it. I have enabled verbose output from aop.xml but I am not seeing any weaving messages, errors or otherwise. Where does aspectJweaver look for the META-INF/aop.xml? How can I tell which one it is looking for?

I have attempted to use a direct path to import the xml with this, but it hasn't worked. -Dorg.aspectj.weaver.loadtime.configuration=C:\dev\trunk\bin\META-INF\aop.xml

Note: The program works as intended with compile-time-weave, but I would prefer to use load-time-weave. I have also been able to implement load-time-weave using small test cases.


回答1:


The META-INF folder must be on the root of the classpath. And the META-INF folder must contain the file aop.xml.

For standalone programs, you must start the JVM with a weaving Java agent. For example:

-javaagent:pathto/aspectjweaver.jar

With Spring:

-javaagent:pathto/spring-agent.jar

You can find more information about it on AspectJ's Development Environment Guide.

If you use a web container, you have to configure the container to do the load-time weaving. SpringSource's reference guide shows you how to enable load-time weaving with Tomcat.



来源:https://stackoverflow.com/questions/9418001/how-does-aspectjs-load-time-weaver-find-meta-inf-aop-xml

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