一、Maven項目,右鍵-update project后JRE system Library變為JavaSE1.6
1 Dynamic Web Module 3.0 requires Java 1.6 or newer. 2 spring-aop line 1 Maven Java EE Configuration Problem
pom.xml文件中添加以下內容:
1 <build> 2 <plugins> 3 define the project compile level 4 <plugin> 5 <groupId>org.apache.maven.plugins</groupId> 6 <artifactId>maven-compiler-plugin</artifactId> 7 <version>2.3.2</version> 8 <configuration> 9 <source>1.8</source> 10 <target>1.8</target> 11 </configuration> 12 </plugin> 13 </plugins> 14 </build>
但所有項目總要加這段,感覺太麻煩了。所以繼續查找原因,執行了maven的update指令才改變了項目的JRE版本,那么應該是maven的默認jdk版本問題。
查閱資料后,發現maven的settings.xml文件中有個標簽可以配置maven的jdk版本。一般安裝maven的時候無需指定,使用的是maven默認的。因此,只需要將其改為指定的版本即可,相關配置如下:
修改maven的配置文件setting.xml,找到<profiles>,然后在之間添加以下內容:
<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>
添加完上面的內容,先將項目的JRE system Library改為JavaSE-1.7,再次執行maven的update project后,發現成功了。項目的JRE環境版本沒變。問題得到解決!!!