欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【Maven】Fatal error compiling: invalid target release: 1.7 -> [Help 1] 博客分类: MavenEclipse compiling1.7 

程序员文章站 2024-03-24 16:44:58
...

问题: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

 

解决:

1、mvn -v 显示结果如下,

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、pom设置如下:

 <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、但是java -version 的结果如下:

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、编译没有使用到1.7,设置maven的java home  为1.7(本机设置了多版本的jdk)

修改maven的配置,java_home指向 1.7 ,/etc/mavenrc 和 ~/.mavenrc。两个文件默认不存在,需要新建,可以任选一个

比如:vi  ~/.mavenrc

写入:

JAVA_HOME=`/usr/libexec/java_home -v 1.7`

 

5、再mvn -v ,结果如下:

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、解决

 

 

本文来源于:http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece7631046893b4c4380146d96864968d4e414c42246170735b2e6617943588d9820321cfc091ab1a168252a5577f1c893d60bc0bd972a2b8a20357508c31c528516f89a187e8361c74de9de4db4fca36c84aea3849f140e8a44050bd1add4185b4a9133a5033093b1983b025f61b9fa3115e859003e9e5345&p=882a9644d78516f80be296214b0a95&newp=8b2a9713949f1fb40cbd9b7d0c17cf231610db2151d6d0106b82c825d7331b001c3bbfb423231401d7c1766c00ab495be8f63d703d0923a3dda5c91d9fb4c57479de65682e07d2&user=baidu&fm=sc&query=eclipse+Fatal+error+compiling%3A++1%2E7&qid=d7c4336e00028582&p1=2

【Maven】Fatal error compiling: invalid target release: 1.7 -> [Help 1]

相关标签: compiling 1.7