Maven问题
【不支持源选项5。请使用7或更高版本】问题解决方案
1. 问题
不支持源选项5。请使用7或更高版本。不支持目标选项5。请使用7或更高版本
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 
 | [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ springmvc_03_request_mapping ---
 [INFO] Changes detected - recompiling the module!
 [WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
 [INFO] Compiling 4 source files to E:\java\Javaganji\spring\02-springmvc\02-springmvc\day01\源码\springmvc\springmvc_03_request_mapping\target\classes
 [INFO] -------------------------------------------------------------
 [ERROR] COMPILATION ERROR :
 [INFO] -------------------------------------------------------------
 [ERROR] 不再支持源选项 5。请使用 7 或更高版本。
 [ERROR] 不再支持目标选项 5。请使用 7 或更高版本。
 [INFO] 2 errors
 [INFO] -------------------------------------------------------------
 
 | 
2. 问题原因
maven的setings.xml文件中默认是JDK1.4版本,需要加载更高版本的JDK才行。
3. 解决办法
3.1 暂时解决
在pom.xml文件中指定的jdk版本,运行另一个项目,需要在另一个项目的pom.xml文件中再配置一个,每换一个项目,都需要在pom.xml中配置一个,所以是暂时解决的。
| 12
 3
 4
 5
 6
 7
 
 | <properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
 <java.version>1.8</java.version>
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
 </properties>
 
 | 
3.2 永久解决
在maven配置文件settings.xml文件中在每次运行maven用指定的jdk版本
把下面的代码放到<profiles></profiles>标签的中间才能生效
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 
 | <profile>  <id>jdk-1.8</id>
 <activation>
 <activeByDefault>true</activeByDefault>
 <jdk>1.8</jdk>
 </activation>
 <properties>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>
 </properties>
 </profile>
 
 |