我是靠谱客的博主 鲜艳外套,这篇文章主要介绍SpringBoot读取properties文件中的值SpringBoot读取properties文件中的值,现在分享给大家,希望可以做个参考。

SpringBoot读取properties文件中的值

properties文件(test.properties)

复制代码
1
2
3
4
5
xx.xyz.url=http://www.xxx.com/ xx.xyz.name=zhangsan xx.xyz.clientId=1234456 xx.xyz.clientSecret=miyao

config配置文件

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.test.sso.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; @Configuration @PropertySource("classpath:test.properties") @ConfigurationProperties(prefix = "xx.xyz") //配置文件属性统一前缀 @Data public class HuanXinConfig { private String url; private String name; private String clientId; private String clientSecret; }

最后

以上就是鲜艳外套最近收集整理的关于SpringBoot读取properties文件中的值SpringBoot读取properties文件中的值的全部内容,更多相关SpringBoot读取properties文件中内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(88)

评论列表共有 0 条评论

立即
投稿
返回
顶部