zoukankan      html  css  js  c++  java
  • source 1.5 中不支持 switch 中存在字符串

    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

  • 相关阅读:
    使用树莓派打造远程WEB服务器
    oracle 12c新建pdb实例
    word标题变成黑色方块解决
    idea 报JDBC连接失败原因之一
    maven项目pom.xml需要的一些配置
    Mysql时区无法识别
    数据库报ORA-12514
    win10无法在桌面右键快捷打开个性化设置、显示设置,在任务栏右键无法快捷打开任务栏设置
    Tomcat部署项目时,发布的项目页面部分乱码,且页面渲染文件也是乱码。
    高性能、高稳定性的跨平台MQTT客户端
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313984.html
Copyright © 2011-2022 走看看