将公共的配置抽取出来,写在配置类中,以便后期的维护
- 首先创建一个Springboot项目
- 在resources文件夹下创建一个
config.properties(文件名随意)文件,在这个文件中配置要抽取的公共配置

方式一 - 写一个读取配置类
package com.lemon.common;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
@Data
@Component
@PropertySource

最低0.47元/天 解锁文章
9732

被折叠的 条评论
为什么被折叠?



