04. Spring Boot 2.4 Profile 적용 안되던 문제
문제
원인
Spring Boot 2.4 버전 부터 application profile 을 작성하는 방식이 달라졌습니다 (아래 참고)
http://honeymon.io/tech/2021/01/16/spring-boot-config-data-migration.html
[spring-boot] 2.4 부터 변경된 구성파일 처리방식 살펴보기 - I'm honeymon(JiHeon Kim).
스프링 부트 2.4(https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4-Release-Notes) 출시노트를 살펴보면 인상적인 2가지가 있다. 애플케이션 구성파일(application.yml 혹은 application.properties)의 작동방식
honeymon.io
https://stackoverflow.com/questions/64907675/including-profiles-in-spring-boot-2-4-0-version
Including profiles in spring boot 2.4.0 version
As a developer, I use the default dev profile in my local development environment. Here is part of my application-dev.properties file: # Profiles spring.profiles.include=auth Previously I used
stackoverflow.com
해결
이전 방식
# application.yml
spring:
profiles:
include: app, h2, oauth2
# 결과적으로는 app , h2, oauth2-naver, oauth2-kakao, oauth2-google 이 설정된다
# application-h2.yml
spring:
datasource:
url: jdbc:h2:mem:testdb
username: sa
password:
jpa:
show-sql: true
hibernate:
ddl-auto: create
properties:
hibernate:
format_sql: true
h2:
console:
enabled: true
# application-app.yml
app:
test: 'appConfig'
# application-oauth2.yml
spring:
profiles:
include: naver, kakao, google
---
spring:
profiles: naver
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
---
spring:
profiles: kakao
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
---
spring:
profiles: google
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
---
spring:
profiles: facebook
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
---
spring:
profiles: github
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
변경된 방식
# application.yml
spring:
profiles:
group:
local:
- h2
- app
- oauth2
prod:
- h2
- app
active: local
# 결과적으로 local( h2, app, oauth2-naver, oauth2-kakao, oauth2-google) 로 설정 된다
# application-app.yml
app:
test: 'appConfig'
# application-h2.yml
spring:
datasource:
url: jdbc:h2:mem:testdb
username: sa
password:
jpa:
show-sql: true
hibernate:
ddl-auto: create
properties:
hibernate:
format_sql: true
h2:
console:
enabled: true
# application-oauth2.yml
spring:
config:
import:
- classpath:/oauth2/application-naver.yml
- classpath:/oauth2/application-kakao.yml
- classpath:/oauth2/application-google.yml
profiles:
group:
- naver
- kakao
- google
# /oauth2/application-naver.yml
spring:
profiles: naver
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
# /oauth2/application-kakao.yml
spring:
profiles: kakao
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
# /oauth2/application-google.yml
spring:
profiles: google
security:
oauth2:
client:
registration:
naver:
# client id, client-secret, redirect-uri, scope, client-name
provider:
naver:
# authorization_uri, token_uri, user-info-uri, user_name_attribute
'∞. 트러블 슈팅 + TIL' 카테고리의 다른 글
06. Spring Security OAuth JWT Test (0) | 2021.09.08 |
---|---|
05. Spring Boot 2.4 Test 와 Profile (0) | 2021.09.08 |
03. Spring Boot 2.x CrossOrigin 문제 (0) | 2021.09.08 |
02. JPA Querydsl cannot find symbol 에러 (0) | 2021.09.08 |
01. Vue 2 Sass Loader 문제 (0) | 2021.09.08 |
댓글
이 글 공유하기
다른 글
-
06. Spring Security OAuth JWT Test
06. Spring Security OAuth JWT Test
2021.09.08 -
05. Spring Boot 2.4 Test 와 Profile
05. Spring Boot 2.4 Test 와 Profile
2021.09.08 -
03. Spring Boot 2.x CrossOrigin 문제
03. Spring Boot 2.x CrossOrigin 문제
2021.09.08 -
02. JPA Querydsl cannot find symbol 에러
02. JPA Querydsl cannot find symbol 에러
2021.09.08