如何配置aspectj以进行编译后编织(使用maven)?

时间:2014-02-10 14:13:17

标签: maven configuration aspectj pom.xml load-time-weaving

如何配置AspectJ以进行编译后编织?我刚刚在下面的插件中用“post-compile”替换了“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

1 个答案:

答案 0 :(得分:4)

See http://www.mojohaus.org/aspectj-maven-plugin/examples/weaveJars.html.

The jars 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.