在向AspectJ添加依赖项时,m2e插件中的Eclipse Luna出错

时间:2014-10-04 07:20:08

标签: eclipse maven aspectj

我正在尝试在项目中使用AspectJ。当我尝试在我的pom.xml中添加maven插件aspectj-maven-plugin时,我收到此错误:

  

生命周期配置未涵盖的插件执行:org.codehaus.mojo:aspectj-maven-plugin:1.7:compile(执行:默认,阶段:编译)

我已经尝试安装AspectJ工具包+ AspectJ m2e连接器,但是每次注释都会出错,因为编译级别似乎不是1.5或更高。

我的设置是:Eclipse Luna + Java EE7 + JDK8。

我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.dickschmeck</groupId>
<artifactId>housekeepingbook-web</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>war</packaging>
<name>Web Project</name>
<description>Web Project</description>

<properties>
    <junit.version>4.11</junit.version>
    <log4j.version>2.0.2</log4j.version>
    <primefaces.version>4.0</primefaces.version>
</properties>

<dependencies>
    <!-- Java EE 7 dependency -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>

    <!-- JSR-330 -->
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

    <!-- JSF -->
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.5</version>
        <scope>provided</scope>

    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.5</version>
        <scope>provided</scope>

    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>

    <!-- Primefaces -->
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>5.0</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces.themes</groupId>
        <artifactId>all-themes</artifactId>
        <version>1.0.10</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.2.2.Final</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.2.Final</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.0.2.GA</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>
    <!-- log4j -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>${log4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${log4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.3.2</version>
    </dependency>

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>1.8.2</version>
    </dependency>

</dependencies>
<repositories>
    <repository>
        <id>prime-repo</id>
        <name>PrimeFaces Maven Repository</name>
        <url>http://repository.primefaces.org</url>
    </repository>
</repositories>
<build>

    <plugins>
        <!-- Avoid war plugin complaining missing web.xml -->
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.7</version>
        <configuration>
            <complianceLevel>1.8</complianceLevel>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
        <executions>
            <execution>
                <goals>
                    <goal>compile</goal>
                    <goal>test-compile</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
        <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <version>1.0.0.Final</version>
            <configuration>
                <hostname>${wildfly-hostname}</hostname>
                <port>${wildfly-port}</port>
                <username>${wildfly-username}</username>
                <password>${wildfly-password}</password>
            </configuration>
        </plugin>

    </plugins>

</build>

非常感谢您的答案!

2 个答案:

答案 0 :(得分:0)

我不完全理解你的问题,但如果我告诉你为了获得Luna的AJDT(AspectJ开发工具)版本,可能会有所帮助,目前你需要使用

http://download.eclipse.org/tools/ajdt/44/dev/update/

这样的POM似乎没问题,至少它适用于IntelliJ IDEA中的空项目或Maven命令行。

答案 1 :(得分:0)

这更像m2e​​插件的问题或怪癖,并不是aspectj特有的 - 这也是它在@kriegaex的IntelliJ IDEA中工作的原因。

这是Eclipse-Wiki的相关网站,解释原因:http://wiki.eclipse.org/M2E_plugin_execution_not_covered

This question存在同样的问题,一种可能的解决方案似乎是添加相应的<pluginManagement> - 代码,如最高投票答案所述。

另请注意,此错误仅适用于Eclipse 中的应用程序的构建。它与maven构建无关,如果你只是通过maven构建你的项目,可以安全地忽略它 - Eclipse为错误建议的快速修复应该提供忽略错误的选项。