背景
使用 maven 3.x 安裝到本地後,建立的項目一般都是基于JDK1.5版本。而目前大多數的項目已經更新到1.6或以上,尤其是Servlet3.0 已經要求Java6或以上版本的環境,往往需要改動。
解決方案
方案一:全局設定
在${MAVEN_HOME}/conf/setting.xml中改變預設的編譯版本,激活profile:
<profile>
<id>jdk1.6</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.6</jdk>
</activation>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.compilerVersion>1.6</maven.compiler.compilerVersion>
</properties>
</profile>
方案二:項目單獨配置
修改pom檔案中,加入以下配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>

作者:
zale出處:
http://www.cnblogs.com/littleatp/, 如果喜歡我的文章,請
關注我的公衆号本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出
原文連結如有問題, 可留言咨詢.