无法找到aspectj-maven-plugin的依赖项

时间:2014-02-06 07:17:38

标签: java maven aop aspect

我使用aspectj-maven-plugin解决了CTW方面的问题。我收到以下错误(突出显示执行条目):

Multiple annotations found at this line:
    - Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.5:compile failed: Plugin 
     org.codehaus.mojo:aspectj-maven-plugin:1.5 or one of its dependencies could not be resolved: Could not find artifact 
     com.sun:tools:jar:1.7.0_21 at specified path C:\Program Files\Java\jre7/../lib/tools.jar (org.codehaus.mojo:aspectj-maven-
     plugin:1.5:compile:default:compile)
    - Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.5:test-compile failed: Plugin 
     org.codehaus.mojo:aspectj-maven-plugin:1.5 or one of its dependencies could not be resolved: Could not find artifact 
     com.sun:tools:jar:1.7.0_21 at specified path C:\Program Files\Java\jre7/../lib/tools.jar (org.codehaus.mojo:aspectj-maven-
     plugin:1.5:test-compile:default:test-compile)

在配置上:

<build>
        <plugins>
            <!-- http://mojo.codehaus.org/aspectj-maven-plugin/usage.html -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.5</version>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                    <outxml>true</outxml>
                    <source>1.7</source>
                    <target>1.7</target>
                    <sources>
                        <source>
                            <basedir>src/main/java</basedir>
                            <includes>
                                <include>**/*Aspect.java</include>
                            </includes>
                        </source>
                    </sources>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

我做错了什么?看起来好像这个插件无法找到jdk?但为什么呢?

3 个答案:

答案 0 :(得分:0)

您的JAVA_HOME设置正确吗?请检查一下。它对我来说很完美。所以我认为你应该添加下面提到的插件并尝试:

<plugin>      
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
   </plugin>

之后运行mvn compile

答案 1 :(得分:0)

请检查JAVA_HOME env变量。当JAVA_HOME指向JRE文件夹而不是jdk文件夹时,这发生在我身上。

答案 2 :(得分:0)

我在运行 java 11 时遇到了这个问题,似乎它只与 java 8 兼容。

查看项目,aspectj-maven-plugin 看起来更新已提交但从未真正合并。