Search code examples
javaintellij-ideawarningsaccess-levels

Intellij IDEA give a 'Access can be private' warning for @Bean


I am using the latest IntelliJ IDEA free version (2018.1 build july 11.2018). The code analysis gives me a warning: 'Access can be private' on the method decorated with @Bean.

I searched this problem, but all of answer suggested me to disable this check.

I was wondering is there anyway that I can only disable the check with @Bean rather than totally disabled?


Solution

  • You could use IntelliJ IDEA Ultimate edition, which does not have this problem. IntelliJ IDEA Community edition does not include the Spring plugin This is why it does not know about the @Bean annotation.

    Another solution may be to add the @Bean annotation as Entry Point in the settings for the Java | Declaration redundancy | Unused declaration inspection. Then it won't be reported as 'Access can be private'. A disadvantage of this solution is that it also will not be reported as unused, if it isn't used.