---
# System prepended metadata

title: Maven Compilier Version
tags: [Maven, Compilier Version]

---

# Maven Compilier Version
###### tags: `Maven` `Compilier Version`
maven Compiler如果沒特別指定則預設使用java 1.5編譯
在調整project's java verison時，沒特別指定則會導致專案版本問題



在pom.xml特別指定
1.

		<properties>
		  <maven.compiler.target>1.8</maven.compiler.target>
		  <maven.compiler.source>1.8</maven.compiler.source>
		</properties>
2.

		<plugins>  
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.7</source>
					<target>1.7</target>
					<encoding>UTF-8</encoding>
				</configuration>
			</plugin>
		</plugins>

在maven setting.xml指定

		<profile>  
			<id>jdk-1.8</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>