-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
프로파일 분리 완료 #63
Merged
Merged
프로파일 분리 완료 #63
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
192a36f
setting: 프로파일별 yml 설정 분리 #61
mungsil 2511f4f
setting: 프로파일별 env.properties 로드 #61
mungsil 2747e36
setting: 배포 시 prod 프로파일 활성화 #61
mungsil a63e874
fix: 불필요한 파일 삭제 #61
mungsil 60fecf0
fix: 적절한 환경변수 파일이 전달되도록 스크립트 수정 #61
mungsil b8b3cde
fix: 도커 컴포즈 환경변수 설정 #61
mungsil fe6ea71
feat: 배포 테스트용도로 push branch 임시 변경 #61
mungsil 7fab8bf
fix: 잘못된 디렉토리 경로 수정 #61
mungsil 3f2f690
fix: 테스트 코드 주석 해제 #61
mungsil 74d4394
fix: 테스트 용도의 Redis 분리 #61
mungsil 1b7760a
feat: 경고 메시지 제거 #61
mungsil b2e769e
fix: event push branch 복구 #61
mungsil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/munecting/api/global/config/DevConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.munecting.api.global.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
@Configuration | ||
@Profile("dev") | ||
@PropertySource(value = {"classpath:env-common.properties", "classpath:env-dev.properties"}) | ||
public class DevConfig { | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/com/munecting/api/global/config/EmbeddedRedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.munecting.api.global.config; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import jakarta.annotation.PreDestroy; | ||
import org.redisson.Redisson; | ||
import org.redisson.api.RedissonClient; | ||
import org.redisson.config.Config; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import redis.embedded.RedisServer; | ||
|
||
@Configuration | ||
@Profile("test") | ||
public class EmbeddedRedisConfig { | ||
|
||
@Value("${spring.data.redis.host}") | ||
private String host; | ||
|
||
@Value("${spring.data.redis.port}") | ||
private int port; | ||
|
||
private RedisServer redisServer; | ||
|
||
@PostConstruct | ||
public void startEmbeddedRedis() { | ||
redisServer = new RedisServer(port); | ||
redisServer.start(); | ||
} | ||
|
||
@PreDestroy | ||
public void stopEmbeddedRedis() { | ||
if (redisServer != null) { | ||
redisServer.stop(); | ||
} | ||
} | ||
|
||
@Bean | ||
public RedissonClient redissonClient() { | ||
Config config = new Config(); | ||
config.useSingleServer() | ||
.setAddress("redis://" + host + ":" + port); | ||
return Redisson.create(config); | ||
} | ||
|
||
} |
8 changes: 4 additions & 4 deletions
8
...ing/api/global/config/PropertyConfig.java → ...necting/api/global/config/ProdConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.munecting.api.global.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.context.annotation.PropertySources; | ||
|
||
@Configuration | ||
@PropertySources({ | ||
@PropertySource("classpath:env.properties") | ||
}) | ||
public class PropertyConfig { | ||
@Profile("prod") | ||
@PropertySource(value = {"classpath:env-common.properties","classpath:env-prod.properties"}) | ||
public class ProdConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/munecting/api/global/config/TestConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.munecting.api.global.config; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.context.annotation.PropertySource; | ||
import org.springframework.context.annotation.PropertySources; | ||
|
||
@Configuration | ||
@Profile("test") | ||
@PropertySource(value = {"classpath:env-common.properties", "classpath:env-test.properties"}) | ||
public class TestConfig { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
/* | ||
|
||
package com.munecting.api; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
@@ -14,4 +14,4 @@ void contextLoads() { | |
} | ||
|
||
} | ||
*/ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 파일은 테스트용 redis의 환경변수 값을 주입하기 위한 클래스인가요?
만약 그렇다면 아래쪽의 RedisConfig와 차이점이 무엇인가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 파일은 말씀해주신 테스트용 redis의 환경변수 값을 주입하기 위한 목적도 가지고 있지만, 실제 레디스 서버 대신 EmbeddedRedis를 사용하기 위함이기도 합니다.
두 Config는 어느 환경에 위치한 레디스를 사용해야하는가에 따라 나누었는데요, 아시다시피 개발 환경과 배포 환경에서는 각각 로컬 또는 EC2 컨테이너로 존재하는 실제 Redis 서버를 사용하고 있어요.
따라서 RedisConfig는 외부 Redis 서버를 사용하기 위한 설정을 수행하고 있습니다.
반면 테스트 환경에서는 실제 Redis 서버 대신 내장된 레디스 서버(EmbeddedRedis)를 사용하려고 합니다.
그러므로 EmbeddedRedis를 사용하기 위한 설정을 따로 분리하였습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이해했습니다! 답변 감사합니다