Spring Boot的多环境开发!!!

需求:

        application-dev.yml 开发环境 端口8090

        application-test.yml 测试环境 端口8091

        application-prod.yml 生产环境 端口8092

方案:配置多环境开发。

1、不同名称的yml文件对应不同的环境。

Spring Boot的多环境开发!!!_第1张图片

 application-dev.yml:(其余的开发环境就省略了)

spring:
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3305/springboot
    username: root
    password:
    type: com.alibaba.druid.pool.DruidDataSource

server:
  port: 8080

2、在application.yml文件中开启使用dev开发环境。

#激活指定的配置文件
spring.profiles.active=dev

 

你可能感兴趣的:(spring,boot,java,linux)