Java SuppressWarnings注解用法(抑制警告)

小郝不负流年
小郝不负流年   + 关注
2021-09-14 09:47:20   阅读332   评论0

  • @SuppressWarnings配置参数抑制接口中各种警告
  • 1. @SuppressWarnings("unchecked") [^ 抑制单类型的警告]
  • 2. @SuppressWarnings("unchecked","rawtypes") [^ 抑制多类型的警告]
  • 3. @SuppressWarnings("unchecked") [^ 抑制所有类型的警告]


  • 关键字    用途
  • all    to suppress all warnings (抑制所有警告)
  • boxing    to suppress warnings relative to boxing/unboxing operations (抑制装箱、拆箱操作时候的警告)
  • cast    to suppress warnings relative to cast operations (抑制映射相关的警告)
  • dep-ann    to suppress warnings relative to deprecated annotation (抑制启用注释的警告)
  • deprecation    to suppress warnings relative to deprecation (抑制过期方法警告)
  • fallthrough    to suppress warnings relative to missing breaks in switch statements (抑制确在switch中缺失breaks的警告)
  • finally    to suppress warnings relative to finally block that don’t return (抑制finally模块没有返回的警告)
  • hiding    to suppress warnings relative to locals that hide variable(抑制相对于隐藏变量的局部变量的警告)
  • incomplete-switch    to suppress warnings relative to missing entries in a switch statement (enum case)(忽略没有完整的switch语句)
  • nls    to suppress warnings relative to non-nls string literals( 忽略非nls格式的字符)
  • null    to suppress warnings relative to null analysis( 忽略对null的操作)
  • rawtypes    to suppress warnings relative to un-specific types when using generics on class params( 使用generics时忽略没有指定相应的类型)
  • restriction    to suppress warnings relative to usage of discouraged or forbidden references( 抑制禁止使用劝阻或禁止引用的警告)
  • serial    to suppress warnings relative to missing serialVersionUID field for a serializable class( 忽略在serializable类中没有声明serialVersionUID变量)
  • static-access    to suppress warnings relative to incorrect static access( 抑制不正确的静态访问方式警告)
  • synthetic-access    to suppress warnings relative to unoptimized access from inner classes( 抑制子类没有按最优方法访问内部类的警告)
  • unchecked    to suppress warnings relative to unchecked operations( 抑制没有进行类型检查操作的警告)
  • unqualified-field-access    to suppress warnings relative to field access unqualified( 抑制没有权限访问的域的警告)
  • unused    to suppress warnings relative to unused code( 抑制没被使用过的代码的警告)
文章来源:https://blog.csdn.net/qq_40237472/article/details/100154474
对我有用,我要     转载  
文章分类: Java基础  
所属标签: SuppressWarnings  
  • 0条评论
  • 只看作者
  • 按时间|按热度
  • 由于本人多次涉及需要打印这个证明,而每次都会忘记入口,在网上各种搜索各种摸索很是浪费时间。故本次将操作流程整理记录下来,以备忘。同时也分享给大家。1、打开湖北政务服务网,地址:http://zwfw.hubei.gov.cn/s/index.html2、切换区域到“武汉市”3、在“特色服务”模块找到“(个人)武汉市社会保险公共服务平台”4、进入“(个人)武汉市社会保险公共服务平台”,登录账号密码<imgsrc="https://cdnstatic.hoscen.cn/blog/article/184053017752895488/img/497065960be44747825acb86a17483c1.png"style=
  • java中的注解@Generated用来标注源代码中的某些东西是由某些工具生成的,而不是人写的。这个注解可以用于:包、类、注解类、方法、构造方法、变量、本地变量、方法参数。
  • 如何使用postman模拟http发送xml参数报文的POST请求?1、postman工具通过安装软件或使用谷歌插件都可以,这里不再赘述。2、配置postman,选择POST,填写URL;切换到Headers,添加Content-Type:text/xml 3、切换到body,选择raw,XML,下方填写你的请求报文4、点击Send发送请求,如图可以看到响应状态、时间、结果等信息5、讲到这里就结束了,是不是学会了?快去试试吧!
  • 解决办法:是idea的加载有问题,关闭IDEA,在工程的根目录下删除.idea文件,重新打开IDEA加载就好了。
  • Failedtoloadprojectconfiguration:cannotparsefileF:/xx/.idea/modules.xml:ParseErrorat[row,col]:[1,1]Message:文件提前结束。解决办法:关闭idea,删掉这个文件,重新打开idea
  • 建立服务器内网其他IP端口的隧道,可以将远程的服务映射到本地进行访问。finalshell配置隧道方法:
  • 上传图片微服务网关报错:UT000054:Themaximumsize1048576foranindividualfileinamultipartrequestwasexceeded原因:所用容器对文件的限制一般项目用的是spring 对spring参数进行配置即可spring:servlet:multipart:#MultipartPropertiesmax-request-size:10MB#总文件大小max-file-size:10MB#单个文件大小注意如果是nginx代理配置限制,报错信息里面会标记nginx。届时需要设置nginx在server_name下加上client_max_body_size20m;
  • 目录:1、安装node.js环境2、安装cnpm3、安装vue-cli脚手架构建工具4、用vue-cli构建项目5、安装项目所需的依赖6、项目运行7、项目打包1、安装node.js环境下载地址:https://nodejs.org/zh-cn/安装过程没有太多好说的,安装完成后 win+R打开命令行输入node -v , 如图,出现版本号说明安装成功。npm包管理器是集成在node中的 , npm -v可以查看版本2、安装cnpm由于有些npm有些资源被屏蔽或者是国外资源的原因,经常会导致用npm安装依赖包的时
  • 控制台信息:Unabletostartthedaemonprocess.Thisproblemmightbecausedbyincorrectconfigurationofthedaemon.Forexample,anunrecognizedjvmoptionisused.PleaserefertotheUserManualchapteronthedaemonathttps://docs.gradle.org/6.3/userguide/gradle_daemon.htmlProcesscommandline:E:\DevelopTools\Java\OpenJDK8U-jdk_x86-32_windows_hotspot_8u282b08\jdk8u282-b08\bin\java.exe-XX:MaxHeapSize=1024m-Xms1024m-Xmx2048m-Dfile.encoding=UTF-8-Duser.country=CN-Duser.language=zh-Duser.variant-cpE:\DevelopTools\gradle-6.8.2-all\gradle_resp\wrapper\dists\gradle-6.3-bin\8tpu6egwsccjzp10c1jckl0rx\gradle-6.3\lib\gradle-launcher-6.3.jarorg.gradle.launcher.daemon.bootstrap.GradleDaemon6.3Pleasereadthefollowingprocessoutputtofindoutmore:-----------------------ErroroccurredduringinitializationofVMCouldnotreserveenoughspacefor2097152KBobjectheapPickedupJAVA_
  • 问题maven同一个版本号部署远程仓库,出现报错:Returncodeis: 400,ReasonPhrase:Repositorydoesnotallowupdatingassets:maven-releases. 解决maven在部署(deploy)时候抛的异常,存储库不允许更新资产,这个就是和私有maven库更新策略有关。具体设置步骤:1.访问私有库管理界面http://xxx.xxx.xxx.xxx:80812.登录管理员账号(默认:admin/admin123)3.进入设置界面->repository->repositories->maven-releases(自己需要部署的目标库)->setting->Deploymentpollcy(Allowredeploy)允许更新