简体   繁体   English

Eclipse Maven插件未针对正确的Java版本进行编译

[英]Eclipse Maven Plugin not compiling against correct java version

I am quite new to using maven and I am using STS as a development environment. 我对使用Maven非常陌生,并且正在将STS用作开发环境。 I have amended my pom file to indicate that my project should compile with java 7 yet regardless of what I do it always marks the manifest as using jdk 1.6. 我已经修改了pom文件,以指示我的项目应该使用Java 7进行编译,但是无论我做什么,它始终会将清单标记为使用jdk 1.6。

<properties>
    <java-version>1.7</java-version>        
</properties>

<build>
    <plugins>
         <plugin>
           <artifactId>maven-compiler-plugin</artifactId>
             <version>3.0</version>         
             <configuration>
               <compilerVersion>1.7</compilerVersion>
               <source>1.7</source>
               <target>1.7</target>
             </configuration>
         </plugin>
     </plugins>
 </build>

What do I need to do to get it to pick up that my project is 1.7? 我需要做些什么才能使它达到我的项目1.7? Here is the text from the manifest for the project which always indicates 1.6: 这是项目清单中的文本,始终表示1.6:

Manifest-Version: 1.0
Built-By: pao
Build-Jdk: 1.6.0_25
Created-By: Maven Integration for Eclipse

The folder target\\m2e-wtp\\web-resources\\META-INF\\MANIFEST.MF is generated through the Maven integration you are using inside Eclipse and it is configured to be using JDK 1.6, either default or explicitly. 文件夹target \\ m2e-wtp \\ web-resources \\ META-INF \\ MANIFEST.MF是通过您在Eclipse中使用的Maven集成生成的,并且已配置为使用JDK 1.6(默认或显式)。

Change the configuration in your eclipse making sure your project is configured to use jdk 1.7. 在eclipse中更改配置,确保将项目配置为使用jdk 1.7。

I have the same problem 我也有同样的问题

Manifest-Version: 1.0
Built-By: MrD
Build-Jdk: 1.8.0
Created-By: Maven Integration for Eclipse

vs ( package ): vs( package ):

Manifest-Version: 1.0
Built-By: MrD
Build-Jdk: 1.7.0_25
Created-By: Apache Maven 3.2.1
Archiver-Version: Plexus Archiver

I have no java 8 jdk in eclipse (namely in Preferences > Java > Installed JREs). 我在Eclipse中没有java 8 jdk(即在“偏好设置”>“ Java”>“已安装的JRE”中)。 I believe it's a bug - I reported here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=437668 我相信这是一个错误-我在这里报告: https//bugs.eclipse.org/bugs/show_bug.cgi?id = 437668

Nevertheless I am not sure it actually builds with JDK 8 - maybe it just reports this wrongly ? 但是,我不确定它实际上是与JDK 8一起构建的 -也许只是报告错误了?

Had a similar issue with the version in the manifest file. 清单文件中的版本存在类似问题。 It was remedied by changing the eclipse launch parameters to use the intended jvm. 通过更改eclipse启动参数以使用预期的jvm进行了补救。 (which can also be done on the command line.) For me updating eclipse.ini to include: (也可以在命令行上完成。)对我来说,将eclipse.ini更新为包括:

-vm C:\\Java\\jdk1.7.0_60\\bin\\javaw.exe -vm C:\\ Java \\ jdk1.7.0_60 \\ bin \\ javaw.exe

(I chose the jdk version for other reasons too) (我出于其他原因也选择了jdk版本)

Then updated projects using maven plugin and all worked. 然后使用maven插件更新了项目,并且一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM