背景: 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