源代码:

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. 平衡树Splay

    维护区间添加,删除,前驱,后继,排名,逆排名 普通平衡树 #include <cstdio> #define ls t[now].ch[0] #define rs t[now].ch[1] ...

  2. luogu4185 [USACO18JAN]MooTube (并查集)

    类似于NOI2018d1t1的离线做法,把询问存下来,排个序,然后倒着给并查集加边,每次询问并查集联通块大小 #include<bits/stdc++.h> #define ll long ...

  3. hdu 2158 最短区间版大家来找碴(尺取法)

    Problem Description 给定一个序列,有N个整数,数值范围为[0,N).有M个询问,每次询问给定Q个整数,可能出现重复值.要求找出一个最短区间,该区间要包含这Q个整数数值.你能找的出来 ...

  4. 上下文管理协议with_open,__enter__和__exit__(三十八)

    在操作文件对象的时候可以这么写 with open('a.txt') as f: '代码块' 上述叫做上下文管理协议,即with语句,为了让一个对象兼容with语句,必须在这个对象的类中声明__ent ...

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

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

  6. python在数据处理中常用的模块之matplotlib

    <利用python进行数据分析>读书笔记--第八章 绘图和可视化 python 画子图(add_subplot & subplot)

  7. idea 注释中的错误不再提示

  8. (大数 小数点) 大明A+B hdu1753

    大明A+B Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  9. H5新特性之canvas

    canvas无疑是H5之中最受欢迎的新特性了,它可以让浏览毫无费力的画出各种图案,动画. canvas的性能不会因为画布上的图案多少而改变,因此做动画用canvas性能也相当优秀. canvas最基本 ...

  10. 20190312 Windows上Kafka集群

    1. 复制config/server.properties为server1.properties和server2.properties 2. 以server1.properties为例,修改配置 br ...