Springboot静态变量注入_springboot component 注入statics变量-CSDN博客

网站介绍:文章浏览阅读1k次。在Springboot中注入静态变量@Componentclass MyComp{ @Autowire MyObject mo;}//√@Componentclass MyComp{ @Autowire static MyObject mo;}//× mo为null解决方法:@PostConstruct@Componentclass MyComp{ @Autowired MyObject t_mo; static MyObject mo; @PostConstr_springboot component 注入statics变量