简体   繁体   English

如何使用aspectj-maven-plugin

[英]How to use aspectj-maven-plugin

I'm a newbie to AspectJ and Maven. 我是AspectJ和Maven的新手。

I'm trying to use aspectj-maven-plugin to build my project, but it does not work. 我正在尝试使用aspectj-maven-plugin来构建我的项目,但它不起作用。 I just followed the steps in AspectJ In Action 2 nd Edition . 我只是按照AspectJ In Action 2 nd Edition中的步骤进行操作

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>

                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Here's the error message I get on the <execution> line: 这是我在<execution>行上得到的错误消息:

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (execution: default, phase: compile) 生命周期配置未涵盖的插件执行:org.codehaus.mojo:aspectj-maven-plugin:1.4:compile(执行:默认,阶段:编译)

I'm using JDK6 and Apache Maven 3.0.4. 我正在使用JDK6和Apache Maven 3.0.4。

You need to install the AspectJ Maven configurator. 您需要安装AspectJ Maven配置程序。 It is available here: 它可以在这里:

http://dist.springsource.org/release/AJDT/configurator/ http://dist.springsource.org/release/AJDT/configurator/

Help -> Install new software... 帮助 - >安装新软件......

Add this update site to the "work with" section and select the feature. 将此更新站点添加到“使用”部分并选择该功能。

To resolve this plugin execution issue with aspectj-maven-plugin, you can wrap your 要使用aspectj-maven-plugin解决此插件执行问题,您可以打包 tag with 标记 tag in your pom.xml. 在你的pom.xml中标记。 This will remove the exception in eclipse. 这将删除eclipse中的异常。

Shown as below: 如下图所示:

<build>
    ....
    <pluginManagement>
        <plugins>
            <plugin> ... </plugin>
             ....
             ....
        </plugins>
    </pluginManagement>
</build>

You can add like this : 您可以像这样添加:

<executionManger><execution>...<execution/><executionManger/>

it will be working 它会起作用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM