问题描述
当我在项目上运行maven软件包时,我已将JAVA_HOME变量设置为C:\Program Files\Java\jre6\
,它告诉我无法解决依赖关系
I have JAVA_HOME variable set to C:\Program Files\Java\jre6\
when I run maven package on the project it tells me that it can't resolve dependency
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.0:compile (default) on project roo: Execution default of goal o
rg.codehaus.mojo:aspectj-maven-plugin:1.0:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.0 or one of its dependencies
could not be resolved: Could not find artifact com.sun:tools:jar:1.4.2 at specified path C:\Program Files\Java\jre6/../lib/tools.jar ->
[Help 1]
因此,它假设JAVA_HOME实际上比实际深度更深一层,我查看了maven本地存储库,发现log4j 1.2.16使用了这种依赖关系
so it assumes that JAVA_HOME is actually one level deeper than it actually is, I have looked through maven local repository and found that log4j 1.2.16 uses this dependency
我试图使JAVA_HOME看起来像C:\Program Files\Java\jre6\bin\
,但是随后maven无法运行,它告诉我我的JAVA_HOME路径错误
I tried to make JAVA_HOME look like C:\Program Files\Java\jre6\bin\
but then maven wouldnt run, it told me that my JAVA_HOME path was wrong
推荐答案
您将需要Java JDK,而不仅仅是JRE.您可以在 Oracle的Java页面
You will need a Java JDK not just a JRE. You can get one at Oracle's Java Page
从 Maven属性指南:
${java.home} specifies the path to the current JRE_HOME environment use with relative paths to get for example:
<jvm>${java.home}../bin/java.exe</jvm>
例如,在c:\jdk
中使用JDK,行家$ {java.home}指向c:\jdk\jre
And with a JDK for example in c:\jdk
the maven ${java.home} is pointing to c:\jdk\jre
这篇关于JAVA_HOME和Maven依赖关系的怪异问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!