How do I figure out and change which version of Java Maven is using to execute?

前端 未结 4 2197
温柔的废话
温柔的废话 2020-12-14 05:14

When running our Maven build, a member of my team gets an error when executing. However, when we run java -version from her command line, it indicates Java 1.6.

4条回答
  •  悲&欢浪女
    2020-12-14 06:02

    mvn -version tells you what compiler Maven is using, so this answers the question unless your POM specifies override values for the versions to be used.

    Here's the easiest way to specify the overrides in pom.xml:

    
        1.9
        1.9
    
    

    Alternatively, the maven-compiler-plugin can be specified more explicitly. In that case, look at the and values associated with the plugin.

    Both of these options are described here.

    If your POM has a , then you need to check that as well (recursively).

    Note: When source and target are specified, these values are passed as command-line options to the compiler. Using this feature, you can compile or run against earlier Java versions than the compiler's nominal value.

提交回复
热议问题