源代码:

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的更多相关文章

  1. Python问题:UnboundLocalError: local variable 'xxx' referenced before assignment

    参考链接: http://blog.csdn.net/onlyanyz/article/details/45009697 https://www.cnblogs.com/fendou-999/p/38 ...

  2. 解决Python报错:local variable 'xxx' referenced before assignment(引)

    解决Python报错:local variable 'xxx' referenced before assignment(引) 解决Python报错:local variable 'xxx' refe ...

  3. python的UnboundLocalError: local variable 'xxx' referenced b

    一.意思: 本地变量xxx引用前没定义. 二.错误原因     在于python没有变量的声明 , 所以它通过一个简单的规则找出变量的范围 :如果有一个函数内部的变量赋值 ,该变量被认为是本地的,所以 ...

  4. [合集]解决Python报错:local variable 'xxx' referenced before assignment

    a = 1 def use(): print(a) #输出1 引用不会报错 a = 1 def use(): a = 3 print(a) #输出 3 重新赋值也不会报错. 局部变量会优先在函数内部去 ...

  5. python: local variable 'xxx' referenced before assignment

    问题发现 xxx = 23 def PrintFileName(strFileName): if xxx == 23: print strFileName xxx = 24 PrintFileName ...

  6. Python UnboundLocalError: local variable 'xxx' referenced before assignment 解决方法

    一.报错含义: val=9 def test(): print(val) val = 6 print(val) test() 翻译:本地变量xxx引用前没有定义. 二.报错原因 这是Python变量作 ...

  7. 遇到local variable 'e' referenced before assignment这样的问题应该如何解决

    问题:程序报错:local variable 'e' referenced before assignment 解决:遇到这样的问题,说明你在声明变量e之前就已经对其进行了调用,定位到错误的地方,对变 ...

  8. 变量引用的错误:UnboundLocalError: local variable 'range' referenced before assignment

    class Battery(): """一次模拟电瓶汽车的简单尝试""" def __init__(self,battery_size = ...

  9. 关于header file、static、inline、variable hides的一点感想

    前言 先看一段代码 #ifndef _INLINE_H #define _INLINE_H template<typename T> static inline T my_max(T a, ...

随机推荐

  1. [POI2010]KLO-Blocks——一道值得思考的题

    题目大意: 给出N个正整数a[1..N],再给出一个正整数k,现在可以进行如下操作:每次选择一个大于k的正整数a[i],将a[i]减去1,选择a[i-1]或a[i+1]中的一个加上1.经过一定次数的操 ...

  2. Java: 在不同windows主题下,JFrame窗口设置最佳高度的解决方案

    //设置窗口的大小,无论使用怎样的windows主题,都能灵活的应对,显示合适的窗口大小,一定要在JFrame.setVisible(true)之前调用, //替代传统的frame.setSize(w ...

  3. 描述符__get__(),__set__(),__delete__()(三十七)

    http://www.cnblogs.com/linhaifeng/articles/6204014.html#_label12 描述符是什么:描述符本质就是一个新式类,在这个新式类中,至少实现了__ ...

  4. 在exe运行界面按右键(不用按鼠标右键)

    单击该键 用于夜晚在exe运行界面粘贴数据.(正常来说直接按右键即可) 从此粘贴数据不会影响睡觉的人……etc.在宿舍……

  5. MyEclipse添加模板注释

    只有两个步骤: 1.设置模板 Windows—Preference—Java—Code Style—Code Templates 图中, Configure generated code and co ...

  6. passat / maintenance / baoyang

    s s 南京迎客隆汽车租赁有限公司 / 地址:常府街54号 / 电话:025-84546836 84507610 二手车养不起.修不起?果真如此吗?http://www.che168.com/list ...

  7. Windows计划任务提示 0xE0434352 错误

    写了一个计划任务每周去跑一个程序,但是并没有跑,报错是 0xE0434352,应该是没有找到路径(计划任务这么菜的吗)... 解决办法:双击启动程序 写上你当前程序的起始路径 然后在运行一下,就成功了

  8. html 高亮显示表格当前行【转】

    html在线模拟网:http://www.w3school.com.cn/tiy/t.asp?f=html_basic 高亮显示表格当前行 <html> <head> < ...

  9. idea常用快捷键及自定义快捷键汇总

    以下都是挨个进行验证过的 生成get和set方法为:alt+insert 自动补全返回值,自动补全变量名称和属性名称:ctrl+alt+v 输入System.out.println()的快捷方法是:输 ...

  10. Keil5下载STM32库

    1.http://www.keil.com/dd2 2.3.以STM32L051C8为例 下载即可.