Spring Boot 资源配置文件读取

1. pom.xml 需要添加 spring-boot-configuration-processor


    org.springframework.boot
    spring-boot-configuration-processor
    true

2. 创建资源配置文件

    例如属性为:

com.merverille.name=the_sardine
com.merverille.age=20
com.merverille.sex=1

3. 创建实体类 读取资源配置

        创建和访问自定义配置设

@Configuration 
@ConfigurationProperties(prefix = "com.merverille")
@PropertySource(value="classpath:resouces.properties")

你可能感兴趣的:(Spring,Boot)