spring Aspectj-编译时编织外部jar [英] spring aspectj - compile time weaving external jar
问题描述
我有一个使用方面的编译时编织的项目.该项目取决于另一个项目,该项目包含在jar中.我想在编译时在jar文件中编织一个类.我怎么能做到这一点.
I have a project which uses compile time weaving of aspects. this project depends on another project, which is a included as a jar. I want to weave a class in the jar file while compiling. How can i achieve this.
谢谢
推荐答案
此jar需要添加到正在编译的项目的inpath中.结果将是一组新的类文件.这些新的类文件是编织文件,应该在运行时使用,而不是原始的jar.
This jar needs to be added to the inpath of the project being compiled. The result will be a new set of class files. These new class files are the woven ones and should be used at runtime instead of the original jar.
如何设置in路径取决于编译代码的方式:
How to set the in path is dependent on how you compile your code:
- 在Eclipse/AJDT中,您可以在AspectJ Build项目属性页面上设置in路径.在这里,您还可以设置in-path out文件夹,为这些类文件指定特殊位置.
- 通过使用iajc任务的ant,可以使用inpath属性.请参阅此处以获取更多信息: http://www.eclipse.org/aspectj/doc/released/devguide/antTasks-iajc.html
- 使用ajc命令时,请使用
-inpath
选项.参见此处 http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html .
- Within Eclipse/AJDT, you can set the in path on the AspectJ Build project properties page. Here you can also set an in-path out folder to specify a special location for these class files.
- From ant using the iajc task, you can use the inpath attribute. See here for more info: http://www.eclipse.org/aspectj/doc/released/devguide/antTasks-iajc.html
- When using the ajc command, use the
-inpath
option. See here http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html.
棘手的部分是要记住避免在运行的应用程序中使用原始的jar,而要避免使用编织的jar.
The tricky part is to remember to avoid using the original jars in the running application, but rather the woven jars.
这篇关于spring Aspectj-编译时编织外部jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!