본문 바로가기
Spring/Spring Cloud

[Spring Cloud Config] Client yml 환경변수로 작성하기

by hongdor 2021. 2. 22.
728x90

1. Config Server와 연동된 applicationName-profilesName.yml 파일 

 

spring:

  datasource:

    url: jdbc:mysql://ip:port/DatabaseName?serverTimezone=UTC&characterEncoding=UTF-8

      username: id

      password: pw

      driver-class-name: com.mysql.cj.jdbc.Driver

 

  jpa:

    show-sql: true

 

management:

  endpoints:

    web:

      exposure:

        include: ["env", "refresh"]

 

 

2. Client의 application.yml 파일 에서 값 받기 (bootstrap.yml 불필요 최신버전)

 

server:

  port: 8080

 

spring:

  application:

    name: applicationName 

 

  profiles:

    active: profilesName

 

  config:

    import: optional:configserver:http://config-server-IP:port  (optional:configserver 까지는 고정이다)

 

  datasource:

    url: ${spring.datasource.url}

    username: ${spring.datasource.username}

    password: ${spring.datasource.password}

    driver-class-name: ${spring.datasource.driver-class-name}

 

  jpa:

    show-sql: ${spring.jpa.show-sql}

 

management:

  endpoints:

    web:

      exposure:

        include: ${management.endpoints.web.exposure.include[0]}, ${management.endpoints.web.exposure.include[1]}

728x90

댓글0