SpringBoot 配置文件
application.properties 配置
server.port=8080
server.address=localhost
logging.pattern.dateformat=yyyy-MM-dd HH:mm:ss.SSSapplication.yml 配置
server:
port: 4000
spring:
application:
name: SpringBootDemo-01
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/springbootdemo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
username: root
password: 123456
logging:
pattern:
dateformat: yyyy-MM-dd HH:mm:ss.SS
baseDir: /home/user
tempDir: ${baseDir}/temp
# 使用引号包裹的字符串,其中的转译字符会生效,例如\t、\n等转译字符
tempDir01: "${baseDir}\temp"读取配置
使用@Value读取单个配置
使用@ConfigurationProperties读取配置
使用Environment读取配置
使用@PropertySource读取配置
中文乱码
多环境配置
properties 多环境
yaml 多环境配置
多环境切换
一、配置文件指定启动环境
二、通过IDEA编辑器指定项目启动环境
三、通过运行命令指定环境
多环境开发兼容问题
最后更新于