我是靠谱客的博主 鲜艳外套,最近开发中收集的这篇文章主要介绍SpringBoot读取properties文件中的值SpringBoot读取properties文件中的值,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

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;

}

最后

以上就是鲜艳外套为你收集整理的SpringBoot读取properties文件中的值SpringBoot读取properties文件中的值的全部内容,希望文章能够帮你解决SpringBoot读取properties文件中的值SpringBoot读取properties文件中的值所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

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

评论列表共有 0 条评论

立即
投稿
返回
顶部