1. 程式人生 > >Maven 指定JDK版本

Maven 指定JDK版本

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0  http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>king.test.springmvc</groupId
>
<artifactId>spring-mvc-java-config</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <name>SpringMvcJavaConfig</name> <description>...</description> <properties> <project.build.sourceEncoding
>
UTF-8</project.build.sourceEncoding> <encoding>UTF-8</encoding> <java.version>1.8</java.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties
>
<dependencies> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> </project>

使用 IntelliJ 時,一執行 maven build,專案的編譯 jdk 總是會變成 1.5 版本,一開始通過maven-compiler-plugin配置指定都不生效,後來在 <properties> 中指定了<maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target> 才解決,還未探得終極原因。。。