在maven中更改java源代码编译器
我使用SpringBootMaven插件来maven编译我的源代码,因为我希望maven依赖项jar成为我jar的一部分。(有人建议)。我已经根据Java1.7编写了代码,但maven编译器正在尝试使用1.5(maven的默认值)编译它。为了改变它,我将源代码定义为1.7,但它仍在用1.5编译,这是我的pom。xml示例
<build>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.2.RELEASE</version>
<configuration>
<finalName>BAU_Report</finalName>
<source>1.7</source>
<target>1.7</target>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.bau.report.MainClass</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
# 1 楼答案
为pom添加
org.apache.maven.plugins
。xml文件编译器版本的Maven属性可以设置如下
方法1
方法2
# 2 楼答案
如果您使用的是spring boot父pom,则可以在pom中使用此属性快捷方式。xml
# 3 楼答案
您应该使用maven编译器插件
将此添加到构建->;插件部分