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, ...
随机推荐
- 安装 Minio服务
#MINIO SERVER Minio是在Apache License v2.0下发布的对象存储服务器.它与Amazon S3云存储服务兼容. 它最适合存储非结构化数据,如照片,视频,日志文件,备份和 ...
- scrapy 中间件
一.中间件的分类 scrapy的中间件理论上有三种(Schduler Middleware,Spider Middleware,Downloader Middleware),在应用上一般有以下两种 1 ...
- 【ATcoder】Xor Sum 2
题目大意:给定一个 N 个点的序列,求有多少个区间满足\(\oplus_{i=l}^ra[i]=\sum\limits_{i=l}^ra[i]\). 题解: 小结论:\(a\oplus b=a+b\r ...
- 2018 ACM 网络选拔赛 徐州赛区
A. Hard to prepare #include <cstdio> #include <cstdlib> #include <cmath> #include ...
- java代码示例(5)
/** * 需求分析:从键盘输入5名学员某门课程的笔试成绩,并求出五门成绩的总成绩和平均成绩 * @author chenyanlong * 日期:2017/10/14 */ package com. ...
- [python网络编程]使用scapy修改源IP发送请求
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...
- 记录一次iptables端口转发的配置
需求是公网访问2.2.2.22的80端口,直接转发到内网的192.100.100.178的80端口上. 代理服务器的,两个不同的网卡 eth0 2.2.2.22 eth1 192.100.100.10 ...
- .Net MVC个人笔记
关于转向的问题,目前知道的是Response.Redirect 和 location.href 我现在有两个controller,Home和Test <h2>this is Home< ...
- iPhone电源键坏了怎么开机和关机?
一.开机 1.将USB数据线插到iPhone上,此时先不要将另一头插到电脑上 2.长按Home键不要动 3.将数据线的另一头插到电脑上 这时iPhone就会自动开机 二.关机 1.进入设置找到“通用” ...
- 纯js异步无刷新请求(只支持IE)【原】
纯js异步无刷新请求 下载地址:http://pan.baidu.com/s/1slakL1F 所以因为非IE浏览器都禁止跨域请求,所以以只支持IE. <HTML> <!-- 乱码( ...