How does AspectJ's load-time-weaver find META-

2019-04-09 18:16发布

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条回答
Deceive 欺骗
2楼-- · 2019-04-09 18:26

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.

查看更多
登录 后发表回答