maven报错:不再支持源选项 5。请使用 6 或更高版本。

问题描述

在构建某个maven项目的时候发生了异常,遇到以下错误,理论上是由于没有指定JAVA版本导致的。

  • [ERROR] 不再支持源选项 5。请使用 6 或更高版本。
  • [ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。
D:\software\jdk10\bin\java.exe "-Dmaven.multiModuleProjectDirectory=D:\workspace\idea with spring\cqs" "-Dmaven.home=D:\software\IntelliJ IDEA Community Edition\plugins\maven\lib\maven3" "-Dclassworlds.conf=D:\software\IntelliJ IDEA Community Edition\plugins\maven\lib\maven3\bin\m2.conf" "-javaagent:D:\software\IntelliJ IDEA Community Edition\lib\idea_rt.jar=60907:D:\software\IntelliJ IDEA Community Edition\bin" -Dfile.encoding=UTF-8 -classpath "D:\software\IntelliJ IDEA Community Edition\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.2 clean compile package
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building CertQuerySystem Maven Webapp 3.2
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom
Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-jar-plugin/2.4/maven-jar-plugin-2.4.pom (0 B at 0.0 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/com/jfinal/jfinal/maven-metadata.xml
Downloaded: http://maven.aliyun.com/nexus/content/groups/public/com/jfinal/jfinal/maven-metadata.xml (668 B at 0.8 KB/sec)
Downloading: http://maven.aliyun.com/nexus/content/groups/public/com/jfinal/jfinal/2.3-SNAPSHOT/maven-metadata.xml
Downloading: http://maven.aliyun.com/nexus/content/groups/public/com/jfinal/jfinal/3.1-SNAPSHOT/maven-metadata.xml
Downloading: http://maven.aliyun.com/nexus/content/groups/public/com/jfinal/jfinal/3.2-SNAPSHOT/maven-metadata.xml
Downloading: http://maven.aliyun.com/nexus/content/groups/public/com/jfinal/jfinal/3.3-SNAPSHOT/maven-metadata.xml
Downloading: http://maven.aliyun.com/nexus/content/groups/public/com/jfinal/jfinal/3.4-SNAPSHOT/maven-metadata.xml
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ CertQuerySystem ---
[INFO] Deleting D:\workspace\idea with spring\cqs\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ CertQuerySystem ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ CertQuerySystem ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 17 source files to D:\workspace\idea with spring\cqs\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] 不再支持源选项 5。请使用 6 或更高版本。
[ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.702 s
[INFO] Finished at: 2018-08-02T22:53:45+08:00
[INFO] Final Memory: 13M/50M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project CertQuerySystem: Compilation failure: Compilation failure:
[ERROR] 不再支持源选项 5。请使用 6 或更高版本。
[ERROR] 不再支持目标选项 1.5。请使用 1.6 或更高版本。
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1

解决方案

pom.xml文件中增加maven编译的java.version jdk版本设置,以及maven.compiler.source 资源编译jdk版本设置和maven.compiler.target 资源构建jdk版本设置

For JAVA6~8,一般都是1.6,1.7,1.8的写法。至于1.9用的人少,我也不知道写1.9还是9。

     <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> 

For JAVA≥10,例如10以上,都是直接写10,11,12,13,14的。

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <java.version>14</java.version>
        <maven.compiler.source>14</maven.compiler.source>
        <maven.compiler.target>14</maven.compiler.target>
</properties>
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 博客之星2020 设计师:CY__ 返回首页