AspectJ的加载时间编织器如何找到META-INF \ aop.xml? [英] How does AspectJ's load-time-weaver find META-INF\aop.xml?
问题描述
我正在尝试使用加载时编织将perf4j绑定到程序中,但似乎没有在类路径中找到aop.xml.要么就是没有找到方面,要么就是没有编织方面.我已经启用了aop.xml的详细输出,但没有看到任何编织消息,错误或其他信息. AspectJweaver在哪里寻找META-INF/aop.xml?我怎么知道它要寻找哪一个?
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?
我尝试使用直接路径与此一起导入xml,但没有成功. -Dorg.aspectj.weaver.loadtime.configuration = C:\ dev \ trunk \ bin \ META-INF \ aop.xml
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.
推荐答案
META-INF文件夹必须位于类路径的根目录下.并且META-INF文件夹必须包含文件aop.xml.
The META-INF folder must be on the root of the classpath. And the META-INF folder must contain the file aop.xml.
对于独立程序,必须使用编织Java代理启动JVM. 例如:
For standalone programs, you must start the JVM with a weaving Java agent. For example:
-javaagent:pathto/aspectjweaver.jar
使用Spring:
-javaagent:pathto/spring-agent.jar
您可以在AspectJ的开发环境指南中找到有关它的更多信息. .
You can find more information about it on AspectJ's Development Environment Guide.
如果使用Web容器,则必须配置该容器以进行加载时编织. SpringSource的参考指南向您展示了如何使用Tomcat启用加载时编织.
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.
这篇关于AspectJ的加载时间编织器如何找到META-INF \ aop.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!