[Single-file version] java SpringBoot switches between different operating environments (production environment, development environment, test environment) SpringBoot configures multiple different operating environments

Background: The same set of Spring Boot applications will be installed in different environments, such as: development, testing, production, etc. Among them, the most modified ones are nothing more than database address, server port and other configurations, [single file solution]

yml but the configuration file switches the operating environment code


#当前项目运行环境
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

Use the method of - to achieve environment segmentation

insert image description here

Guess you like

Origin blog.csdn.net/gjwgjw1111/article/details/131114706