Maven: Viewing compile options?

前端 未结 1 840
离开以前
离开以前 2021-01-24 20:31

I\'m trying to track down this compile error:

$ mvn compile
...
[ERROR] /.../Reader.java:[14,13] try-with-resources is not supported in -source 1.5
(use -source          


        
1条回答
  •  旧时难觅i
    2021-01-24 21:06

    This is because you are using a plain vanilla pom.xml that you have this issue.

    By default, the maven-compiler-plugin, which is called when compiling the sources, compiles with Java 5, whatever you have set up as $JAVA_HOME:

    Also note that at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with.

    To use a different compiler version (e.g. Java 8), you can set the following properties:

    
      1.8
      1.8
    
    

    or configure the plugin directly:

    
      maven-compiler-plugin
      3.3
      
        1.8
        1.8
      
    
    

    0 讨论(0)
提交回复
热议问题