4

我对使用 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?但为什么?

4

3 回答 3

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

于 2014-02-06T07:32:31.557 回答
0

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

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

于 2021-04-21T01:06:41.507 回答
0

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

于 2019-03-18T06:22:30.363 回答