본문 바로가기
IT/Spring

Spring Boot Profile(application.yml)

by 민쌍 2021. 4. 8.

Profile Include

Spring Boot ~2.4

spring.application.name: "customers"
---
spring.profiles: "production"
spring.profiles.include: "mysql,rabbitmq"
---
spring:
  profiles: "mysql"
  datasource:
    url: "jdbc:mysql://localhost/test"
    username: "dbuser"
    password: "dbpass"
---
spring:
  profiles: "rabbitmq"
  rabbitmq:
    host: "localhost"
    port: 5672
    username: "admin"
    password: "secret"

Spring Boot 2.4~

spring:
  application:
    name: "customers"
  profiles:
    group:
      "production": "mysql,rabbitmq"
---
spring:
  config:
    activate:
      on-profile: "mysql"
  datasource:
    url: "jdbc:mysql://localhost/test"
    username: "dbuser"
    password: "dbpass"
---
spring:
config:
  activate:
    on-profile: "rabbitmq"
  rabbitmq:
    host: "localhost"
    port: 5672
    username: "admin"
    password: "secret"

Spring Boot Run

SPRING_PROFILES_ACTIVE=production

spring-projects/spring-boot

728x90
반응형

'IT > Spring' 카테고리의 다른 글

WebFlux vs MVC(Reactive vs Servlet)  (0) 2021.05.02
Spring, nginx proxy HATEOAS  (0) 2021.04.07
QueryDsl Version Error  (0) 2021.03.17
Spring Mongo Database (Multi Database) #2  (0) 2021.02.28
Spring Mongo Database (Multi Database) #2  (0) 2021.02.24