【发布时间】:2020-05-06 04:07:41
【问题描述】:
我在这里遇到一个奇怪的错误,maven 无法使用 sudo。
当我执行mvn clean install -DskipTests
我收到了这个错误:
Failed to execute goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke (default) on project http: Execution default of goal org.fortasoft:gradle-maven-plugin:1.0.8:invoke failed: Plugin org.fortasoft:gradle-maven-plugin:1.0.8 or one of its dependencies could not be resolved: Failed to collect dependencies at org.fortasoft:gradle-maven-plugin:jar:1.0.8 -> org.gradle:gradle-tooling-api:jar:2.13: Failed to read artifact descriptor for org.gradle:gradle-tooling-api:jar:2.13: Could not transfer artifact org.gradle:gradle-tooling-api:pom:2.13 from/to gradle (http://repo.gradle.org/gradle/libs-releases-local/): Access denied to: http://repo.gradle.org/gradle/libs-releases-local/org/gradle/gradle-tooling-api/2.13/gradle-tooling-api-2.13.pom , ReasonPhrase:Forbidden. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
然后我尝试了sudo mvn clean install -DskipTests
奇怪的是我得到了这个错误:
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
执行mvn -v后
Apache Maven 3.6.0
Maven home: /usr/share/maven
Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: /home/akshay/java/jdk1.8.0_251/jre
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "5.3.0-45-generic", arch: "i386", family: "unix"
如果使用 sudo sudo mvn -v 执行
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
我的环境变量:
export JAVA_HOME=/home/akshay/java/jdk1.8.0_251
export PATH=$PATH:$JAVA_HOME/bin
【问题讨论】:
-
快速提示,每当你需要使用 sudo 运行 maven 时,你就做错了。