SpringBoot读取properties文件中的值

SpringBoot读取properties文件中的值,第1张

SpringBoot读取properties文件中的值 properties文件(test.properties)
xx.xyz.url=http://www.xxx.com/
xx.xyz.name=zhangsan
xx.xyz.clientId=1234456
xx.xyz.clientSecret=miyao
config配置文件
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;

}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/724555.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-26
下一篇 2022-04-26

发表评论

登录后才能评论

评论列表(0条)

保存