Sonar: Instance methods should not write to “static” fields

前端 未结 1 1586
春和景丽
春和景丽 2021-01-17 02:49

I am getting this prompt from Sonar: Instance methods should not write to \"static\" fields

I\'m not quite sure what I need to change to fix this is

相关标签:
1条回答
  • 2021-01-17 03:05

    In fact this method:

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        SemaMonitorProxy.applicationContext = applicationContext;
    }
    

    is an instance method writing to a static field:

    private static ApplicationContext applicationContext
    

    You cannot make the above method static. So the only solution would be to remove the static keyword from the applicationContext declaration.

    private ApplicationContext applicationContext
    
    0 讨论(0)
提交回复
热议问题