我的代码中有这一行:
private transient final Logger logger = LoggerFactory.getLogger(getClass());
我构建了我的项目,pmd 检查告诉我:
The Logger variable declaration does not contain the static and final modifiers.
我可以做什么来解决这个问题?我尝试添加 static 修饰符,但出现以下错误:
Cannot make a static reference to the non-static method getClass() from the type Object
最佳答案
如果您在 main 中使用它,请将其静态化
我会使用这样的记录器
private static final Logger LOG = Logger.getLogger(Main.class.getSimpleName());
关于java - 有关记录器的 Pmd 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25774099/