What causes imported Maven project in Eclipse to use Java 1.5 instead of Java 1.6 by default and how can I ensure it doesn't?

前端 未结 13 2180
情深已故
情深已故 2020-11-27 09:51

I imported a Maven project and it used Java 1.5 even though I have 1.6 configured as my Eclipse default Preferences->Java->Installed JREs.

When I

13条回答
  •  醉酒成梦
    2020-11-27 10:01

    If you want to make sure that newly created projects or imported projects in Eclipse use another default java version than Java 1.5, you can change the configuration in the maven-compiler-plugin.

    • Go to the folder .m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.1
    • Open maven-compiler-plugin-3.1.jar with a zip program.
    • Go to META-INF/maven and open the plugin.xml
    • In the following lines:
      ${maven.compiler.source}
      ${maven.compiler.target}

    • change the default-value to 1.6 or 1.8 or whatever you like.

    • Save the file and make sure it is written back to the zip file.

    From now on all new Maven projects use the java version you specified.

    Information is from the following blog post: https://sandocean.wordpress.com/2019/03/22/directly-generating-maven-projects-in-eclipse-with-java-version-newer-than-1-5/

提交回复
热议问题