배경: 개발, 테스트, 프로덕션 등과 같은 다양한 환경에 동일한 Spring Boot 애플리케이션 세트가 설치됩니다. 그 중 가장 많이 수정된 것은 데이터베이스 주소, 서버 포트 및 기타 구성, [단일 파일 솔루션]입니다.
yml이지만 구성 파일은 운영 환경 코드를 전환합니다.
#当前项目运行环境
spring:
profiles:
active: pro
---
#运行环境配置dev
server:
port: 8014
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/ceshi
username: ceshi
password: PCmxSXHbP
#环境命名
config:
activate:
on-profile: dev
---
#运行环境配置pro
server:
port: 3636
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/ceshi
username: ceshi
password: PCmxSXHbP
#环境命名
config:
activate:
on-profile: pro