在maven更新后,Java版本自动更改为java 1.5 [英] Java version automatically change to java 1.5 after maven update
问题描述
http://qussay.com/2013/09/13/solving-dynamic-web -module-3-0-require-java-1-6-or-newer-in-maven-projects /
- 我将Java构建路径更改为workspace default jre 1.8.0_25
- 然后将java编译器更改为1.8
- 然后更改将pom.xml的java版本更改为1.8
< build>
< plugins>
< plugin>
< groupId> org.eclipse.jetty< / groupId>
< artifactId> jetty-maven-plugin< / artifactId>
< version> 9.1.3.v20140225< / version>
< / plugin>
< plugin>
< groupId> org.apache.maven.plugin< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 3.1< / version>
< configuration>
< source> 1.8< / source>
< target> 1.8< / target>
< / configuration>
< / plugin>
< / plugins>
< / build>
所有这一切,当我点击Maven更新我的java版本自动更改为1.5。另外在上述步骤中,前两步的版本也会自动更改为1.5。如何解决这个问题?
打开您的 pom.xml
并添加以下行:
< properties>
< maven.compiler.source> 1.8< /maven.compiler.source>
< maven.compiler.target> 1.8< /maven.compiler.target>
< / properties>
其中 1.8
是您的Java版本目前的JDK / JRE。另一种方式是将< build>
与 maven-compile-plugin
一起添加为
< build>
< plugins>
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-compiler-plugin< / artifactId>
< version> 3.2< / version> <! - 或任何当前版本 - >
< configuration>
< source> 1.8< / source>
< target> 1.8< / target>
< / configuration>
< / plugin>
< / plugins>
< / build>
I am using eclipse as IDE. When I right click on the project and then click maven update my java version change to 1.5. Here is what I did so far, I followed all the steps listed here
- I changed "Java build path" to "workspace default jre 1.8.0_25"
- Then changed "java compiler" to 1.8
- Then changed "project facets">java>1.8
- Changed pom.xml java version to 1.8
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.3.v20140225</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugin</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
After all this when I click on "Maven update" my java version change to 1.5 automatically. Also in above steps, first two step's version also change to 1.5 automatically. How can I fix this?
Open your pom.xml
file and add the following lines on it:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Where 1.8
is the java version of your current JDK/JRE. Another way of doing this is adding a <build>
with the maven-compile-plugin
as
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version> <!-- or whatever current version -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
这篇关于在maven更新后,Java版本自动更改为java 1.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!