IntelliJ IDEA中的“永远不会分配变量"警告只能“部分"禁止. [英] “Variable is never assigned” warning in IntelliJ IDEA can be suppressed only "partially"
问题描述
Java EE + IntelliJ Idea 2016.3:我已经编写了一个类,并声明了带有@Inject
批注的私有字段.
Java EE + IntelliJ Idea 2016.3: I've written a class and declared a private field with a @Inject
annotation.
通过将javax.inject.Inject
添加到设置->编辑器->检查-> Java->声明冗余->未使用的声明-,我已经成功摆脱了检查结果"窗口中的未使用的声明"通知. >入口点->注释->标记为由注释时隐式写的字段(基于
I have successfully got rid of the "unused declaration" notification from the "inspection results" window by adding javax.inject.Inject
to settings -> editor -> inspections -> Java -> declaration redundancy -> unused declarations -> entry points -> annotations -> mark field as implicitly written when annotated by (based on this post).
不幸的是,该字段仍带有下划线,并且滚动条上存在黄色标记.我应该单独配置还是做错什么?
Unfortunately the field is still underlined and a yellow marker is present on the scroll bar. Do I configure this separately or am I doing something wrong?
推荐答案
有两个单独的警告.有人说该字段从未分配一个值,这是您已禁用的值.另一个说该字段从未使用,这是您收到的警告.
There are two separate warnings. One says the field was never assigned a value, which is the one you have disabled. The other says the field was never used, which is the warning you are getting.
将Inject
添加到设置->编辑器->检查-> java->声明冗余->未使用的声明->入口点->注释->标记为入口点
这篇关于IntelliJ IDEA中的“永远不会分配变量"警告只能“部分"禁止.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!