sonar检查不通过位置:
public class SpringContextHolder implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
SpringContextHolder.applicationContext = applicationContext;
//Make the enclosing method "static" or remove this set.
}
}
解决方法:
public class SpringContextHolder implements ApplicationContextAware {
@Setter
private static volatile ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
setAppCtx(applicationContext);
}
}