sping中 各种注解——@SuppressWarnings注解用法
@SuppressWarnings注解用法
@SuppressWarnings注解主要用在取消一些编译器产生的警告对代码左侧行列的遮挡,有时候这会挡住我们断点调试时打的断点。
如图所示:

这时候我们在方法上加上@SuppressWarnings注解就可以消除这些警告的产生,注解的使用有三种:
@SuppressWarnings("unchecked") [^ 抑制单类型的警告]
@SuppressWarnings("unchecked","rawtypes") [^ 抑制多类型的警告]
@SuppressWarnings("unchecked") [^ 抑制所有类型的警告]
***
> 通过源码分析可知@SuppressWarnings其注解目标为类、字段、函数、函数入参、构造函数和函数的局部变量。建议把注解放在最近进警告发生的位置。
下面列举警告关键字:
| 关键字 | 用途 |
|---|---|
| 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( 抑制没被使用过的代码的警告) |
sping中 各种注解——@SuppressWarnings注解用法的更多相关文章
- java注解 @SuppressWarnings注解用法
@SuppressWarnings注解用法 @SuppressWarnings注解主要用在取消一些编译器产生的警告对代码工具左侧行列提示,但这种警告可以通过注释类型声明来取消 @SuppressWar ...
- Java中@SuppressWarnings注解用法(转)
背景: J2SE提供的最后一个注解是@SuppressWarnings.该批注的作用是给编译器一条指令,告诉它对被批注的代码元素内部的某些警告保持静默. @SuppressWarnings注解允许您选 ...
- @SuppressWarnings注解用法详解
@SuppressWarnings注解用法详解 今天来谈谈@SuppressWarnings注解的作用. J2SE 提供的最后一个批注是 @SuppressWarnings.该批注的作用是给编译器一条 ...
- Spring的注解@SuppressWarnings用法记录
@SuppressWarnings注解用法 @SuppressWarnings注解主要用在取消一些编译器产生的警告对代码左侧行列的遮挡,有时候这会挡住我们断点调试时打的断点. 如图所示: 这时候我们在 ...
- JAVA中@SuppressWarnings注解的作用
eclipse中开发JAVA代码时,经常会出现编译告警符号,影响代码可读性,也影响调试的断点符号正常显示,可以使用@SuppressWarnings注解来抑制这些告警符号的再现.1.抑制单个类型的告警 ...
- @SuppressWarnings注解用法
@SuppressWarnings注解主要用在取消一些编译器产生的警告对代码左侧行列的遮挡,有时候这会挡住我们断点调试时打的断点. 如图所示: 这时候我们在方法上加上@SuppressWarnings ...
- @SuppressWarnings注解用法详解(转)
原文连接https://blog.csdn.net/sysware_carol/article/details/52100580 今天来谈谈@SuppressWarnings注解的作用. J2SE 提 ...
- Java中的反射和注解
前言 在Java中,反射机制和注解机制一直是一个很重要的概念,那么他们其中的原理是怎么样呢,我们不仅仅需要会使用,更要知其然而之所以然. 目录 反射机制 反射如何使用 注解定义 注解机制原理 注解如何 ...
- java自定义注解知识实例及SSH框架下,拦截器中无法获得java注解属性值的问题
一.java自定义注解相关知识 注解这东西是java语言本身就带有的功能特点,于struts,hibernate,spring这三个框架无关.使用得当特别方便.基于注解的xml文件配置方式也受到人们的 ...
随机推荐
- 7.10 Varnish 优化
- 基于Hadoop3.1.2集群的Hive3.1.2安装(有不少坑)
前置条件: 已经安装好了带有HDFS, MapReduce, Yarn 功能的 Hadoop集群 链接: ubuntu18.04.2 hadoop3.1.2+zookeeper3.5.5高可用完全分布 ...
- 使用Picasso实现图片圆角和图片圆形
作者很好的文章访问量缺很少也很难搜到(我这里插个眼以后用的到)作者:先知丨先觉 来源:CSDN 原文:https://blog.csdn.net/github_33304260/article/det ...
- hadoop 配置问题以及HDFS下如何读写文件
辛辛苦苦学两年 ,一举回到解放前!!! 大数据开始学真的头疼 关键是linux你玩的不6 唉难受 hadoop 配置参见博客 http://dblab.xmu.edu.cn/blog/install- ...
- UVA - 536 Tree Recovery (二叉树重建)
题意:已知先序中序,输出后序. #pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio& ...
- POJ 1905:Expanding Rods 求函数的二分
Expanding Rods Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 13780 Accepted: 3563 D ...
- 【pwnable.kr】 memcpy
pwnable的新一题,和堆分配相关. http://pwnable.kr/bin/memcpy.c ssh memcpy@pwnable.kr -p2222 (pw:guest) 我觉得主要考察的是 ...
- return , return true , return false的区别
return true: 返回正确的处理结果. return false : 返回错误的处理结果 和 中断代码继续向下 执行. return: 返回null,起到中断方法执行的效果,只要不r ...
- 自己手动实现简单的双向数据绑定 mvvm
数据绑定 数据绑定一般就是指的 将数据 展示到 视图上.目前前端的框架都是使用的mvvm模式实现双绑的.大体上有以下几种方式: 发布订阅 ng的脏检查 数据劫持 vue的话采用的是数据劫持和发布订阅相 ...
- 计算机操作系统学习(一) Linux常用指令(随时更新)
1.chmod 以下转载至https://blog.csdn.net/summer_sy/article/details/70142475 chmod u+x file.sh 就表示对当前目录下的fi ...