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, ...
随机推荐
- luogu2336 喵星球上的点名 (SA+二分答案+树状数组)
离散化一下然后把姓名串和询问串都放一起做SA 和bzoj3277串类似地,满足某一询问的后缀(就是和这个询问对应的后缀的LCP>=这个询问长度的后缀)的排名也是一个区间,把这个区间二分出来即可 ...
- bzoj5281/luogu4377 Talent Show (01分数规划+背包dp)
就是01分数规划的思路,只不过当把w[i]-r*t[i]>0的选完以后如果w值还没达到要求,那就再01背包dp一下就好了(dp时w值>W的时候就存在W里就不会爆内存了). (跑得很慢..大 ...
- 逆元&欧拉函数
欧拉函数: φ(p)表示小于p的正整数中与p互质的数的个数,称作欧拉函数. 求单个数的欧拉函数时可以利用来求 其中pi为p分解出的质因数,ki表示该质因数的指数 代码: #include<cst ...
- Maven的配置以及Eclipse的设置
配置maven仓库 先找到我们解压的maven的conf目录里面的setting.xml 然后加入我们本地仓库的位置(这里仓库所在文件夹是自定义的,比如:我把它放在了D盘根目录的一个文件夹) ecli ...
- OS + Linux RedHat 6 / redhat 6 configuration / configure / autoconf / make / make install
s These critical programs are missing or too old: as ld http://blog.csdn.net/testcs_dn/article/detai ...
- 安装完office后 在组件服务里DCOM配置中找不到
这个主要是64位系统的问题,excel是32位的组件,所以在正常的系统组件服务里是看不到的 可以通过在运行里面输入 comexp.msc -32 来打开32位的组件服务,在里就能看到excel组件了
- UDP网路会议室的代码
UDP网络会议室视频已经录制好,这里贴上代码仅供参考 MainWindow代码: using System; using System.Collections.Generic; using Syste ...
- js中闭包的概念和用法
闭包:主要的作用是 封装变量,收敛权限.防止变量被污染.比如Jquery框架就运用了大量的闭包.为什么呢? 问个问题?框架是如何来避免你声明的变量和它自带的变量不发生的冲突的?????很明显,需要闭包 ...
- SQL记录-PLSQL基本语法与数据类型
PL/SQL基本语法 PL/SQL是一种块结构的语言,这意味着PL/SQL程序被划分和编写代码的逻辑块.每块由三个子部分组成: S.N. 段和说明 1 声明 此部分开头使用关键字DECLARE.它是一 ...
- 破解excel密码保护【转】
破解excel密码保护 录制一个新宏.内容如下.保存后运行,点几次确定,过一分钟还会再弹出来,再点确定,然后就好了. Public Sub AllInternalPasswords() ' Break ...