源代码:

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. 让一个继承unittest.TestCase的类下的setUp和tearDown只执行一次

    知道unittest单元测试框架的朋友应该都知道, 执行继承了unittest.TestCase的类下每个test开头的方法(就是用例)时,都会执行setUp和tearDown,如下面的例子所示: i ...

  2. 单片机I/O口的结构的详解

    1.什么是源型 漏型?什么是上拉电阻?下拉电阻?什么是 线驱动输出 集电极开路输出,推挽式输出? 我们先来说说集电极开路输出的结构.集电极开路输出的结构如图1所示,右边的那个三极管集电极什么都不接,所 ...

  3. requests+beautifulsoup爬取豆瓣图书

    使用Xpath和BeautifulSoup来解析网页可以说真的很简便. import requests from bs4 import BeautifulSoup from random import ...

  4. A1048. Find Coins

    Eva loves to collect coins from all over the universe, including some other planets like Mars. One d ...

  5. 1063. Set Similarity

    Given two sets of integers, the similarity of the sets is defined to be Nc/Nt*100%, where Nc is the ...

  6. 使用html5获取当前手机的经纬度,并接入百度地图API,查询出当前位置

    最近项目需要,稍微研究一下html5获取当前地理位置的问题. 获取当前位置的经纬度很简单,一句代码就搞定 navigator.geolocation.getCurrentPosition(functi ...

  7. 选择监听事件ItemListener(是否被选择)

    [界面说明] 下拉列表框,选谁谁显示.复选框与单选按钮,输出被选与否的状态.知识点主要代码为: int state = e.getStateChange(); ItemEvent.SELECTED I ...

  8. 在kubernetes中运行单节点有状态MySQL应用

    Deploy MySQL https://kubernetes.io/docs/tasks/run-application/run-single-instance-stateful-applicati ...

  9. Linux实战型企业运维工程师试题测评

    Linux实战型企业运维工程师试题答案 作者:尹正杰      最近在网上看到了一套有意思的面试题,我们一起来看一下这些题怎么破吧,哈哈~我先放在这里,有时间了一起来看看.多学点东西终究是没有坏处的! ...

  10. Shell编程(一)概览

    1. Shell功能 1. 自动化批量系统初始化程序(update.软件安装.时区设置.安全策略.......) 2. 自动化批量软件部署程序(LAMP.LNMP.Tomcat.LVS.Nginx) ...