gpt4 book ai didi

maven - 如何配置aspectj以获得编译后编织(使用maven)?

转载 作者:行者123 更新时间:2023-12-02 12:01:33 24 4
gpt4 key购买 nike

如何配置 AspectJ 以获得编译后编织?我刚刚在下面的插件中将“compile”替换为“post-compile”:(不用说这是不成功的)

<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 文件必须列为 <dependencies/>在 Maven 项目中并列为 <weaveDependencies/><configuration>的aspectj-maven-插件。来自 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>

关于maven - 如何配置aspectj以获得编译后编织(使用maven)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21679502/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com