jenkins checkstyle:local variable hides a field
源代码:
|
1
2
3
4
5
6
7
8
|
//应用上下文private static ApplicationContext applicationContext;public static void setApplicationContextValue(ApplicationContext applicationContext){ SpringContextUtil.applicationContext = applicationContext;}public static ApplicationContext getApplicationContext(){ return applicationContext;} |
Jenkins上的checkstyle提示setApplicationContextValue()方法“hides a field”
该错误提示一般出现在变量的setter方法上,原因是:
It means you've got two different variables with the same name - myBoard. One of them is a field in your class. Another one is a local variable, that is, one that you've declared inside a method.
It's a bad idea to have two variables with the same name. It can make your code very confusing and difficult to maintain.
意思就是两个变量设置了相同的名称,一个是类变量,一个是方法内局部变量,解决方法:
|
1
2
3
|
public static void setApplicationContextValue(ApplicationContext applicationContext1){ SpringContextUtil.applicationContext = applicationContext1;} |
将方法内形参名称改一下,与类变量区分开,比如applicationContext1。
jenkins checkstyle:local variable hides a field的更多相关文章
- Python问题:UnboundLocalError: local variable 'xxx' referenced before assignment
参考链接: http://blog.csdn.net/onlyanyz/article/details/45009697 https://www.cnblogs.com/fendou-999/p/38 ...
- 解决Python报错:local variable 'xxx' referenced before assignment(引)
解决Python报错:local variable 'xxx' referenced before assignment(引) 解决Python报错:local variable 'xxx' refe ...
- python的UnboundLocalError: local variable 'xxx' referenced b
一.意思: 本地变量xxx引用前没定义. 二.错误原因 在于python没有变量的声明 , 所以它通过一个简单的规则找出变量的范围 :如果有一个函数内部的变量赋值 ,该变量被认为是本地的,所以 ...
- [合集]解决Python报错:local variable 'xxx' referenced before assignment
a = 1 def use(): print(a) #输出1 引用不会报错 a = 1 def use(): a = 3 print(a) #输出 3 重新赋值也不会报错. 局部变量会优先在函数内部去 ...
- python: local variable 'xxx' referenced before assignment
问题发现 xxx = 23 def PrintFileName(strFileName): if xxx == 23: print strFileName xxx = 24 PrintFileName ...
- Python UnboundLocalError: local variable 'xxx' referenced before assignment 解决方法
一.报错含义: val=9 def test(): print(val) val = 6 print(val) test() 翻译:本地变量xxx引用前没有定义. 二.报错原因 这是Python变量作 ...
- 遇到local variable 'e' referenced before assignment这样的问题应该如何解决
问题:程序报错:local variable 'e' referenced before assignment 解决:遇到这样的问题,说明你在声明变量e之前就已经对其进行了调用,定位到错误的地方,对变 ...
- 变量引用的错误:UnboundLocalError: local variable 'range' referenced before assignment
class Battery(): """一次模拟电瓶汽车的简单尝试""" def __init__(self,battery_size = ...
- 关于header file、static、inline、variable hides的一点感想
前言 先看一段代码 #ifndef _INLINE_H #define _INLINE_H template<typename T> static inline T my_max(T a, ...
随机推荐
- python操作oracle实战
import cx_Oracle conn = cx_Oracle.connect('ua_test/ua_test@192.32.98.15/oracledb') cur1 = conn.curso ...
- luogu2827 [NOIp2016]蚯蚓 (模拟)
可以直观地想到用优先队列来做,但数据范围是O(n)的 然后我们发现,因为我们每次挑出来的蚯蚓是单调的,所以把每个切成两段后,那两段也是对应单调的 也就是说,算上最一开始的蚯蚓,我们一共维护三个队列,三 ...
- Java -- JDBC 学习--处理Blob
Oracle LOB LOB,即Large Objects(大对象),是用来存储大量的二进制和文本数据的一种数据类型(一个LOB字段可存储可多达4GB的数据).LOB 分为两种类型:内部LOB和外部L ...
- mongodb集群故障转移实践
简介 NOSQL有这些优势: 大数据量,可以通过廉价服务器存储大量的数据,轻松摆脱传统mysql单表存储量级限制. 高扩展性,Nosql去掉了关系数据库的关系型特性,很容易横向扩展,摆脱了以往老是纵向 ...
- Python基础学习(六)
前几天一直在练手廖雪峰老师的python课程,接下来继续学习,由于面向对象编程这一课相对理论便不在此练手,直接上手面向对象高级编程. 一.使用 __slots__ 一般情况下一个class是可以绑定一 ...
- C#控件及常用设计整理
1.窗体 1.常用属性 (1)Name属性:用来获取或设置窗体的名称,在应用程序中可通过Name属性来引用窗体. (2) WindowState属性: 用来获取或设置窗体的窗口状态. 取值有三 ...
- python爬虫 bs4_4select()教程
http://www.w3.org/TR/CSS2/selector.html 5 Selectors Contents 5.1 Pattern matching 5.2 Selector synta ...
- HashMap按照value排序的实现
一.实现的思想 将HashMap中的元素按照Entry<Key,Value>类型存入到LinkedList集合中. 实现自定义排序,对LinkedList集合排序. LinkedList集 ...
- javascript 模块化规范
服务器端规范 - CommonJS Node.js 浏览器端规范 - AMD RequireJS - CMD SeaJS
- Cannot send, channel has already failed:
背景: 一个同事往这个队列发数据,另一个同事从这个队列取数据,进行解析. 这是昨天同事昨天消费者 消费activemq 队列,一开始有正常,运行了一段时间后,发现突然消费者变为零了.因为有监控.之后怎 ...