-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: Spring Data 스캔 개선 #2026
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
base: develop
Are you sure you want to change the base?
Conversation
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.
코멘트 몇가지만 확인해주세요. 👍
+)
- config 패키지를 global 패키지 밖으로 빼주시면 감사드리겠습니다.
- repository 어노테이션은 global 패키지 안에 따로 패키지를 만들어서 보관하면 좋을것 같습니다.
- repository 어노테이션의 이름이 스캔 용도라는게 명확했으면 좋겠습니다.
- 꼭 어노테이션을 붙여야만 스캔이 빨라지나요?
(mongo랑 redis 리포지토리가 적은편이니 이 두개의 경우에만 어노테이션 넣고, 나머지는 그냥 jpa로 인식되게하는 것도 한번 고민해봐도 좋을 것 같습니다.)
import in.koreatech.koin.domain.order.address.model.RoadNameAddressDocument; | ||
|
||
@Repository | ||
@in.koreatech.koin.global.config.repository.MongoRepository |
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.
여기 import 가 필요해요
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.
RoadNameAddressRepository가 MongoRepository를 상속받고 있어서, 풀패스로 나오는 거 같습니다
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.
어노테이션 네이밍 수정하면서 해결됐습니다.
@Profile("!test") | ||
public class MongoConfig { | ||
|
||
} No newline at end of file |
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.
No newline at end of file
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.
해당 커밋에서 발생한 거 같습니다 !
928dd86 여기에서 수정했습니다
@Target(TYPE) | ||
@Retention(RUNTIME) | ||
public @interface MongoRepository { | ||
} No newline at end of file |
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.
No newline at end of file
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.
여기도 동일합니다
public @interface RedisRepository { | ||
} |
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.
줄넘김 필요
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.
bd66e4b 수정했습니다
public @interface MongoRepository { | ||
} |
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.
여기도 줄넘김 필요
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.
38b5a03 수정했습니다
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.
config 패키지를 global 패키지 밖으로 빼주시면 감사드리겠습니다.
f05caa5 수정했습니다.
repository 어노테이션은 global 패키지 안에 따로 패키지를 만들어서 보관하면 좋을것 같습니다.
d2ad960 /global/marker
으로 패키지를 만들어서 옮겼습니다.
repository 어노테이션의 이름이 스캔 용도라는게 명확했으면 좋겠습니다.
edf05e1, b7f660f, c26ffdb 에서 수정했습니다. 해당 작업을 할 때 marker
라는 용어를 접해서 이를 반영했는데, 괜찮으실까요 ? 스캔 용도라는 약간 거리가 먼 거 같은데, 해당 인터페이스가 XXRepository
임을 나타내는 데 괜찮다고 생각합니다.
꼭 어노테이션을 붙여야만 스캔이 빨라지나요? (mongo랑 redis 리포지토리가 적은편이니 이 두개의 경우에만 어노테이션 넣고, 나머지는 그냥 jpa로 인식되게하는 것도 한번 고민해봐도 좋을 것 같습니다.)
추가로 테스트를 진행했습니다.
시나리오 | JPA 스캔 | Mongo 스캔 | Redis 스캔 | 합계 | Root WebApplicationContext: initialization |
---|---|---|---|---|---|
어노테이션 기반 필터링 + JPA 설정 파일 분리 + bootstrapMode 설정 | 185ms(LAZY) + 109ms | 35ms | 51ms | 380ms | 2433ms |
어노테이션 기반 필터링 (JPA, Mongo, Redis) | 301ms | 35ms | 54ms | 390ms | 2250ms |
JPA 어노테이션 삭제 (Mongo, Redis 유지) | 381ms | 37ms | 55ms | 473ms | 2478ms |
JPA 설정 파일 분리 및 bootstrapMode 설정 + JPA 어노테이션 삭제 (Mongo, Redis 유지) | 233ms(LAZY) + 138ms | 32ms | 60ms | 463ms | 2436ms |
어노테이션의 존재 여부에 따라 차이가 존재함은 확실한 거 같습니다.
다만, 재테스트 과정에서 JPA 설정 파일 분리 + bootstrapMode 설정
을 제외하고어노테이션 기반 필터링
만 적용했을 때 개선이 많이 됨을 확인했습니다.
b83e98c에서 다시 수정했습니다.
🔍 개요
🚀 주요 변경 내용
어노테이션 기반 필터링
JPA 설정 파일 분리 및 bootstrapMode 설정
미사용 리파지토리 인터페이스 삭제
💬 참고 사항
store assignment
리파지토리 인터페이스가 어떤 store 전용인지 판별하는 과정
판별 과정
어노테이션 기반 필터링 커밋 : dfd7d30, c0fe762, 38545e5, cfe6757, e9efef3, 3fc227f, 4fe5e56
미사용 리파지토리 인터페이스 삭제 커밋 : f3a6fe7
JPA 설정 파일 분리 및 bootstrapMode 설정 커밋 : 59347ad, 91c3901, a4204a9
해당 커밋 위주로 봐주시면 될 거 같고, 리파지토리 어노테이션이 잘 걸려있는지 한 5번은 본거 같은데 요쪽은 한 번 훝어봐주시면 될 거 같습니다.
✅ Checklist (완료 조건)