问题:Fatal error compiling: invalid target release: 1.7 -> [Help 1]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project bugkillers-core: Fatal error compiling: invalid target release: 1.7 -> [Help 1]
[ERROR]
solve:
1. mvn -v displays the following results,
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00) Maven home: /usr/share/java/apache-maven-3.2.5 Java version: 1.6.0_65, vendor: Apple Inc. Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac"
2. The pom settings are as follows:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin>
3. But the result of java -version is as follows:
java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
4. The compilation did not use 1.7 , set the java home of maven to 1.7 (multi-version jdk is set on this machine)
Modify the maven configuration, java_home points to 1.7 , /etc/mavenrc and ~/.mavenrc. The two files do not exist by default and need to be created. You can choose one
For example: vi ~/.mavenrc
write:
JAVA_HOME=`/usr/libexec/java_home -v 1.7`
5. Then mvn -v , the result is as follows:
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-15T01:29:23+08:00) Maven home: /usr/share/java/apache-maven-3.2.5 Java version: 1.7.0_79, vendor: Oracle Corporation Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/jre Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "10.9.2", arch: "x86_64", family: "mac"
6. Solve