1、错误描述
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Cdmp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Cdmp ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 4 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Cdmp ---
[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 14 source files to F:workspaceCdmp argetclasses
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /F:/workspace/Cdmp/src/main/java/com/you/utils/SQLQuery.java:[54,47] -source 1.5 中不支持 switch 中存在字符串
(请使用 -source 7 或更高版本以允许 switch 中存在字符串)
[ERROR] /F:/workspace/Cdmp/src/main/java/com/you/utils/SQLQuery.java:[143,47] -source 1.5 中不支持 switch 中存在字符串
(请使用 -source 7 或更高版本以允许 switch 中存在字符串)
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.059 s
[INFO] Finished at: 2017-01-10T17:19:35+08:00
[INFO] Final Memory: 13M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Cdmp: Compilation failure: Compilation failure:
[ERROR] /F:/workspace/Cdmp/src/main/java/com/you/utils/SQLQuery.java:[54,47] -source 1.5 中不支持 switch 中存在字符串
[ERROR] (请使用 -source 7 或更高版本以允许 switch 中存在字符串)
[ERROR] /F:/workspace/Cdmp/src/main/java/com/you/utils/SQLQuery.java:[143,47] -source 1.5 中不支持 switch 中存在字符串
[ERROR] (请使用 -source 7 或更高版本以允许 switch 中存在字符串)
[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
2、错误原因
switch语句在jdk1.5之前可以使用byte、boolean、int、short、char,不能使用String;但是在Java程序中用String
3、解决办法
(1)如果用jdk1.5,不能使用String
(2)将jdk版本升级到1.7