How Mac changes the Java version of Maven

Source: Internet
Author: User
Tags locale

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (DEFAULT-COMPILE) on Project API: Fatal error Compiling:invalid Target release:1.7-[Help 1]

invalid target release: 1.7the target version is invalid based on the error prompt.

View Pom.xml File
<plugin>    <artifactId>maven-compiler-plugin</artifactId>          <version>3.2</ version>          <configuration>            <source>1.7</source>            <target>1.7</target >          </configuration>    </plugin>

The target version can be seen according to maven-compiler-plugin the configuration is JDK 1.7;

View JDK version
?  ~  Java-versionjava Version "1.7.0_71" Java (tm) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot (tm) 64-bit Ser Ver VM (build 24.71-b01, Mixed mode)

According to the above information can be seen my JDK version is also 1.7;

So where's the problem?

View maven Information
?  ~  mvn-vapache maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15t01:37:52+08:00) maven home:/usr/ Local/cellar/maven/3.2.1/libexecjava version:1.7.0_71, Vendor:oracle Corporationjava home:/System/Library/Java/ Javavirtualmachines/1.6.0.jdk/contents/homedefault LOCALE:ZH_CN, platform Encoding:utf-8os name: "Mac OS X", Version: " 10.10 ", Arch:" X86_64 ", Family:" Mac "

Finally I really want to, originally Maven refers to the 1.6 version, then how to modify the configuration to 1.7 version?

Originally, Maven read two configuration files, /etc/mavenrc and ~/.mavenrc . Two files default is not, you can choose one to make changes, I choose my user directory ~/.mavenrc , the following code to write.

Java_home= '/usr/libexec/java_home '

If you have more than one version of the JDK installed on your Mac and you don't want to change the default JDK version, you just need to add a version number to the configuration, such as:

Java_home= '/usr/libexec/java_home-v 1.7 '

/usr/libexec/java_homeA connection file that is represented in the Mac java_home .

?  ~  ll/usr/libexec/java_homelrwxr-xr-x  1 root  wheel    79B/16:39/usr/libexec/java_home System/library/frameworks/javavm.framework/versions/current/commands/java_home

Then in the execution

?  ~  mvn-vapache maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15t01:37:52+08:00) maven home:/usr/ Local/cellar/maven/3.2.1/libexecjava version:1.7.0_71, Vendor:oracle Corporationjava home:/Library/Java/ Javavirtualmachines/jdk1.7.0_71.jdk/contents/home/jredefault LOCALE:ZH_CN, platform Encoding:utf-8os name: "Mac OS X" , Version: "10.10", Arch: "X86_64", Family: "Mac"

Then there is no such error in the Install project.

How Mac changes the Java version of Maven

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.