[英]Build Success | Not Getting any error in Maven Project in Eclipse but nothing is happening
[英]Cannot build any maven project with same error
我在 maven 中構建任何東西已經有幾個星期了,我只是嘗試構建其中一個項目,但它給了我這個錯誤。 我嘗試使用多個項目,但它們拋出相同的錯誤:
Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.8 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:15.0.2 at specified path /usr/local/Cellar/openjdk/15.0.2/libexec/openjdk.jdk/Contents/Home/../lib/tools.jar -> [Help 1]
我該如何解決這個錯誤? 我什至不能運行 mvn install -DskipTests 或 mvn package。
我使用的是 JDK 版本 8。
編輯:這是我的 pom 插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>${aspectj-maven-plugin.version}</version>
<configuration>
<complianceLevel>${java.version}</complianceLevel>
<source>${java.version}</source>
<target>${java.version}</target>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<aspectLibraries>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
</dependency>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
java 版本 = 1.8 aspectj-maven-plugin.version = 1.8
編輯:我從 repo 中提取了這個項目,這意味着它可以在其他人的計算機上/在 jenkins 上運行。 我相信這與我的本地計算機有關。 如果我使用終端,它也會給我同樣的錯誤。
經過更多研究,我找到了答案。 正如@Michael Katt 在評論中提到的,我的 JAVA_HOME 沒有正確設置。 當我執行which java
,它給了我/usr/bin/java
,但是當我執行echo $JAVA_HOME
,它什么也沒給我。
所以在其他同事的幫助下,我做了vi ~/.bash_profile
並添加了export JAVA_HOME=$(/usr/libexec/java_home)
。 不完全確定為什么,但這與將它與我的項目結構中的 jdk 匹配有關,該結構具有/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk...
我打開了新的 shell 並輸入echo $JAVA_HOME
,它給了我/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
。 我的項目現在構建/編譯。
我仍然不確定$(/usr/libexec/java_home)
轉換為/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.