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, ...
随机推荐
- 最长公共子序列LCS(POJ1458)
转载自:https://www.cnblogs.com/huashanqingzhu/p/7423745.html 题目链接:http://poj.org/problem?id=1458 题目大意:给 ...
- P1198 最大数 线段树水题
这道题模拟一下可以过,但是我们发现线段树也可以安全水过...... 写的线段树只需要滋磁单点修改,区间求max即可 我一开始犯了一个很SB的错误:每次插入修改了t,然后疯狂爆0到怀疑人生... 而且我 ...
- bug6 项目检出JRE问题(Unbound classpath container: 'JRE System Library [JavaSE-1.7]' in project 'idweb')
项目从SVN检出到工作空间后报了很多错误,其中很明显就是一些jar的问题,没有相关的jar或版本问题,看到最后的错误Unbound classpath Container: 'JRE System L ...
- Object,equals,toString
一.Object类 说明:Object类是Java中所有的类的直接或者间接的父类(基类). 该类中定义的是所有的类中的都有的的功能. 位置:可以从API中查找. 二.Object类之 equals 方 ...
- C++中hpp的适用
本文第一部分转载百度百科,在此感谢百度.第二部分示例为独立编写. hpp,其实质就是将.cpp的实现代码混入.h头文件当中,定义与实现都包含在同一文件,则该类的调用者只需要include该hpp文件即 ...
- MUI 样式按钮的禁用
1)如果是button,input等标签,可以 .attr("disabled",true)或者.attr("disabled","disab ...
- pyglet----画一个矩形
这里列出一种在窗口Window中画图的程序框架.......... #-*- coding:utf-8 -*- from pyglet.gl import * def draw_rect(x, y, ...
- MySQL开启远程连接的方法
默认情况下,mysql只允许本地登录,如果要开启远程连接,则需要修改/etc/mysql/my.conf文件. 一.修改/etc/mysql/my.conf找到bind-address = 127.0 ...
- location对象的一些属性和方法
window.location 对象用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面 以下是window.location的属性 window.location.host 返回主机名或者 ...
- SQL——将表中的最大ID+1插入新的ID中------Insert into 表 MAX(表id) +1
表结构:group表(groupid int,groupname varchar) 表中数据:id name 分组1 分组2 分组3 分组4 ----------------------------- ...