maven一更新jdk版本就变化

问题

  每次更新maven,项目的jdk版本,编译版本就会变成1.5,很奇怪。

背景

  由于公司私服没有某个jar,只能切换为默认配置,从中央仓库下载后上传到私服,结果更新maven后,编译环境就变化。

方案

  发现是setting文件出现问题,需要添加

<profile>
        <id>jdk</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.8</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
            <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
        </properties>
    </profile>

  进入默认的配置文件即可。