解决Java Checkstyle错误:名称'logger'必须匹配模式'^ [A-Z] [A-Z0-9] *(_ [A-Z0-9] +)* $' [英] Resolve Java Checkstyle Error: Name 'logger' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'

查看:3693
本文介绍了解决Java Checkstyle错误:名称'logger'必须匹配模式'^ [A-Z] [A-Z0-9] *(_ [A-Z0-9] +)* $'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Eclipse Checkstyle插件我看到这个错误:

Using the Eclipse Checkstyle plugin I see this error:


名称'logger'必须匹配模式'^ [AZ] [A-Z0-9] *(_ [A-Z0-9] +)* $'

我通过更改以下方法解决了此错误:

I resolved this error by changing:

private static final Logger logger = Logger.getLogger(someClass.class) / code>

private static final Logger logger = Logger.getLogger(someClass.class);

private static final Logger LOGGER = Logger .getLogger(someClass.class);

为什么这是一个checkstyle警告?

推荐答案

因为该字段被标记为 final static 这意味着它是一个常量,应以大写字母命名。

Because the field is marked final and static which implies that it's a constant and should be named with uppercase letters.

此链接,您可以看到模块 ConstantName 格式为 ^ [AZ] [A-Z0- 9] *(_ [A-Z0-9] +)* $ 这正是一个您的Checkstyle插件已指定。

From this link, you can see that the module ConstantName has the format ^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$ which is exactly the one your Checkstyle plugin has specified.

这篇关于解决Java Checkstyle错误:名称'logger'必须匹配模式'^ [A-Z] [A-Z0-9] *(_ [A-Z0-9] +)* $'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆