现在要做的就是将如下配置文件中的内容注入到一个bean 名为Properties中。

Redis.properties配置文件中的内容如下:

Spring boot 将配置文件属性注入到一个bean中

Properties java bean中代码如***意注解的使用:

Spring boot 将配置文件属性注入到一个bean中

测试类代码:

Spring boot 将配置文件属性注入到一个bean中

打印结果为:

Spring boot 将配置文件属性注入到一个bean中

相关文章:

  • 2021-12-27
  • 2021-11-21
  • 2021-05-25
  • 2022-01-07
  • 2022-01-01
  • 2021-10-24
猜你喜欢
  • 2022-01-01
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
相关资源
相似解决方案