Sping使用 @Value 赋值 static 变量

//static 注入 @value  
public static  Boolean DEBUG = false ;

@Value("${MassConstants.debug")
public  void setDEBUG(Boolean dEBUG) {
    DEBUG = dEBUG;
}

注意:该类class 需要 @Component 注解

@Component
public class MassConstants{}

猜你喜欢

转载自blog.csdn.net/qing_mei_xiu/article/details/79976309