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文件配置方式也受到人们的 ...
随机推荐
- spark sortShuffleWriter源码学习
查看的源码为spark2.3 调用ShuffleMapTask的runTask方法 org.apache.spark.scheduler.ShuffleMapTask#runTask ShuffleM ...
- A convenient way to recognize and handwrite multidimensional arrays in Numpy
As a new learner of Numpy, it is very common to be confused by the form of array, braces nested in b ...
- 初玩PLSQL连接 Oracle
1. 官网下载合适的[Instant Client] https://www.oracle.com/database/technologies/instant-client/winx64-64-dow ...
- CAN分帧发送程序说明
试验平台 仅仅 需要一台主机 一台 周立功 CAN 助手, 一个232 助手就OK ICAN 协议 资源节点地址 电脑 我认为是0x01 51单片机主机的地址 是 0x1f 建立连接的 功能码 是0x ...
- 蓝桥杯-机器繁殖 第6届C语言C组决赛第4题
题目叙述: 标题:机器人繁殖 X星系的机器人可以自动复制自己.它们用1年的时间可以复制出2个自己,然后就失去复制能力.每年X星系都会选出1个新出生的机器人发往太空.也就是说,如果X星系原有机器人5个, ...
- 【CF1154G】Minimum Possible LCM
题意 给你 \(n\) 个数 \(a_i\) ,求出 \(\text{lcm}\) 最小的一对数. \(n\le 10^6, a_i\le 10^7\) 题解 直接枚举 ,找到当前数最小的两个倍数,统 ...
- 课程作业02-1-课后作业1-(1)使用组合数公式利用n!来计算
1.设计思想:运用递归阶乘的函数,依次求出n!.k!.(n-k)!,再根据组合数的公式计算(n!/(k!*(n-k)!)). 2.程序流程图: 3.源程序代码: //信1605-3 20163429 ...
- js基础学习之-js包装对象
var test = "test"; test.a = "hello"; console.log(test.a); //undifined 定义: 在JavaS ...
- spring源码 BeanFactory根接口
/* * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Vers ...
- 使用GDI+显示OpenCV中的图像IplImage
OpenCV虽然自带了轻量级的界面库HighGUI,但是支持的图像化元素实在是太少了,一般只在前期算法测试时使用.实际产品还是使用MFC库.因此本文记录了如何在GDI+中显示OpenCV中的IplIm ...