My program has the following code snippet, and I run SonarQube 5 to check the quality of the code after integrating it with Maven.
However, Sonar asks to make the inclusion method "static" or remove this set. method setApplicationContext.
How to remove this error? Why is this error occurring?
public class SharedContext implements ApplicationContextAware {
public static final String REPORT_ENGINE_FACTORY = "reportEngineFactory";
private static ApplicationContext applicationContext;
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
SharedContext.applicationContext = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
public Object getBean(String name) {
return applicationContext.getBean(name);
} }
source
share