SpringBoot配置文件的引用及多环境开发

一、使用@PropertySource 加载配置文件

1. 创建 Spring Boot 项目,添加 Web 依赖。

org.springframework.boot
spring-boot-configuration-processor
true
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test

2. 在项目的类路径下新建一个 test.properties 自定义配置文件,在该配置

文件中编写需要设置的配置属性。
# 对实体类对象 MyProperties 进行属性配置
test.

你可能感兴趣的:(spring,boot,java,spring)