如何配置aspectj以获得编译后编织(使用maven)? [英] How to configure aspectj to get post-compile weaving (with maven)?
本文介绍了如何配置aspectj以获得编译后编织(使用maven)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何配置 AspectJ 以获得编译后编织?我只是在下面的插件中用后编译"替换了编译":(不用说这是不安全的)
How to configure AspectJ in order to get post-compile weaving? I just replaced "compile" with "post-compile" in the plugin below: (needless to say that was unseccessful)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<complianceLevel>1.6</complianceLevel>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<goals>
<goal>post-compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
但我错过了一些东西,因为它给出了以下错误:
'post-compile' was specified in an execution, but not found in the plugin
推荐答案
包含要编织的类的 JAR 文件必须在 Maven 项目中列为
并列为 <在aspectj-maven-plugin的
中的code>
The JAR files containing the classes to weave must be listed as <dependencies/>
in the Maven project and listed as <weaveDependencies/>
in the <configuration>
of the aspectj-maven-plugin. From http://www.mojohaus.org/aspectj-maven-plugin/examples/weaveJars.html:
<project>
...
<dependencies>
...
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.13</version>
</dependency>
<dependency>
<groupId>org.agroup</groupId>
<artifactId>to-weave</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.anothergroup</groupId>
<artifactId>gen</artifactId>
<version>1.0</version>
</dependency>
...
</dependencies>
...
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<weaveDependencies>
<weaveDependency>
<groupId>org.agroup</groupId>
<artifactId>to-weave</artifactId>
</weaveDependency>
<weaveDependency>
<groupId>org.anothergroup</groupId>
<artifactId>gen</artifactId>
</weaveDependency>
</weaveDependencies>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
<build>
...
</project>
这篇关于如何配置aspectj以获得编译后编织(使用maven)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文