在Maven的Java版本不匹配 [英] Java version mismatch in Maven

查看:324
本文介绍了在Maven的Java版本不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的问题,尝试使用Maven构建我的应用程序时,的在命令行上的。 (我见过上的其他问题,指的是在Eclipse构建,或其他一些IDE)

I'm having an odd problem, when attempting to build my application using Maven, on the command line. (Other questions I've seen on SO are referring to building within Eclipse, or some other IDE)

当我试图打造,行家抱怨说,它不能在tools.jar中寻找javac。纵观给定位置,很明显,Maven是看在JRE目录,但是,我似乎无法得到Maven来指向正确的JAVA_HOME为我的JDK - 如何应该是这样的任何想法

When I attempt to build, maven complains that it cannot find Javac in tools.jar. Looking at the given location, it is obvious that Maven is looking in the JRE directory, however, I seem unable to get Maven to point to the correct Java_home for my JDK - any ideas on how this should be done?

环境概述

JAVA_HOME=C:\jdk1.6.0_27
Path=C:\jdk1.6.0_27\bin;...... (showing the jdk is the first thing on the path)

D:\> javac -version
javac 1.6.0_27  <-- This is correct

D:\>java -version
java version "1.6.0_31"  <-- wtf? 

D:\>mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-07 03:16:01+0800)
Java version: 1.6.0_31                       <--- This is the problem - Where
Java home: C:\Program Files (x86)\Java\jre6  <--- does Maven get this from?

您可以摆脱任何对此的光将是最欢迎的。

Any light you could shed on this would be most welcome.

推荐答案

试着在你的Maven目录配置toolchains.xml(如D:\\的maven-2.2.1 \\ CONF)到你的Java版本。

Try Configure the toolchains.xml in your maven directory (e.g D:\maven-2.2.1\conf) to your java version

<toolchains>
<toolchain>
    <type>jdk</type>
    <provides>
        <version>1.5</version> <!--This should be same as is configured via the toolchains plugin -->
        <vendor>ibm</vendor> <!--This should be same as is configured via the toolchains plugin -->
    </provides>
    <configuration>
        <jdkHome>C:\Program Files\Java\jdk1.5.0</jdkHome>
    </configuration>
</toolchain>
</toolchains>

这篇关于在Maven的Java版本不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆