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

使用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:
     profiles:
        active: test

测试

猜你喜欢

转载自www.cnblogs.com/zsg88/p/9163345.html
今日推荐