工具类里@Value取不到值,如下图

Springboot 工具类@Value取不到值

 

Springboot 工具类@Value取不到值

原因是new的对象

Springboot 工具类@Value取不到值

改为

Springboot 工具类@Value取不到值

EncryptIdCardUtil类方法改为非静态方法,ConnectService类由new改为@Autowired注入

Springboot 工具类@Value取不到值

RiskService里也由直接调用EncryptIdCardUtil里的静态方法,改为EncryptIdCardUtil类@Autowired注入

Springboot 工具类@Value取不到值

就可以了

Springboot 工具类@Value取不到值

总结:

[email protected]不能静态成员上使用;
2.使用@Value读取属性值的类对象需要交给spring容器管理。

相关文章:

  • 2021-12-04
  • 2021-05-12
  • 2021-12-20
  • 2022-03-05
  • 2022-12-23
  • 2021-04-16
猜你喜欢
  • 2022-01-16
  • 2021-09-28
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2021-04-29
  • 2022-12-23
相关资源
相似解决方案