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

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

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

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

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

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

测试类代码:

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

打印结果为:

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