我是Maven和MacOS的新手。
我在终端中安装了maven,在获取版本设置(使用mvn -v)时,它似乎使用了JDK 1.6,而我安装了JDK 1.7。有什么问题吗?
mvn -v
我输入的命令如下:
blues:helloworld Ninja$ java -version
java version "1.7.0_05" Java(TM) SE Runtime Environment (build 1.7.0_05-b06) Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)`
blues:helloworld Ninja$ mvn -v
Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-28 10:15:32+0800) Maven home: /usr/local/Cellar/maven/3.1.0/libexec Java version: 1.6.0_51, vendor: Apple Inc. Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: zh_CN, platform encoding: EUC_CN OS name: “mac os x”, version: “10.8.4”, arch: “x86_64”, family: “mac”
Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-28
10:15:32+0800) Maven home: /usr/local/Cellar/maven/3.1.0/libexec Java version: 1.6.0_51, vendor: Apple Inc. Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: zh_CN, platform encoding: EUC_CN OS name: “mac os x”, version: “10.8.4”, arch: “x86_64”, family: “mac”
将以下内容添加到您的~/.mavenrc:
~/.mavenrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/{jdk-version}/Contents/Home
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile