Why Maven project is tied to J2SE-1.5 by default?

前端 未结 3 1171
南笙
南笙 2021-02-07 11:48

If I create default empty based on no archetype Maven project in Eclipse, it will be based on J2SE-1.5.

3条回答
  •  孤街浪徒
    2021-02-07 12:32

    If you want to make sure that newly created 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.7 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/

提交回复
热议问题