spring aspectj - compile time weaving external jar

天涯浪子 提交于 2019-11-29 07:41:51

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.

How to set the in path is dependent on how you compile your code:

  1. 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.
  2. 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
  3. When using the ajc command, use the -inpath option. See here http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html.

The tricky part is to remember to avoid using the original jars in the running application, but rather the woven jars.

If you are using maven, you can use the aspectj-maven-plugin as well. It works well with eclipse (m2e).

In the plugin, just specify the groupId/artifactId of the dependent jar as well in the configuration/weaveDependencies/weaveDepedency.

See http://mojo.codehaus.org/aspectj-maven-plugin/weaveJars.html

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