如果使用Spring Boot搭建项目,可以指定property:
注意java.version
这个参数并不是maven提供的,而是Spring Boot特有的。
如果想单纯的使用maven特性指定,那么有两种方式,它们是等价的。
第一种,指定property:
第二种,使用插件:
插件中的source
和target
属性就是会使用maven.compiler.source
和maven.compiler.target
,如果你指定的话。
source
The -source argument for the Java compiler.
Default value is: 1.6.
User property is: maven.compiler.source.
target
The -target argument for the Java compiler.
Default value is: 1.6.
User property is: maven.compiler.target.
参考:
Specifying java version in maven - differences between properties and compiler plugin
Setting the -source and -target of the Java Compiler