使用application.ym进行多环境配置

1.配置激活选项

spring:
     profiles:
        active: dev   

2.在配置文件添加若干个英文状态下的短横线即可区分

 

spring:
  profiles:
    active: dev
  server:
    port : 8080
    servlet:
      context-path: /demo

  name : hello demo
---
spring:
  profiles: dev
server:
  port : 8082
  servlet:
    context-path: /demo2
name : hello demo dev
---
spring:
  profiles: pro
server:
  port : 8083
  servlet:
    context-path: /demo3
name : hello demo pro
---
spring:
  profiles: test
server:
  port : 8084
  servlet:
    context-path: /demo4
name : hello demo test

 运行测试

Spring Boot 使用IntelliJ IDEA创建一个web开发实例(五)

 

修改激活配置

spring:
     profiles:
        active: test

测试

Spring Boot 使用IntelliJ IDEA创建一个web开发实例(五)

 

相关文章:

  • 2021-07-25
  • 2021-12-04
  • 2021-07-13
  • 2021-10-07
  • 2021-07-13
  • 2021-06-12
  • 2021-06-08
  • 2021-12-21
猜你喜欢
  • 2021-05-28
  • 2022-03-01
  • 2021-12-10
  • 2021-11-21
  • 2021-05-17
  • 2021-12-04
  • 2021-06-13
相关资源
相似解决方案