-
Notifications
You must be signed in to change notification settings - Fork 5
[spring-core-2] ivy.lee(이다예) 과제 제출합니다. #44
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: ivy/spring-core-2
Are you sure you want to change the base?
[spring-core-2] ivy.lee(이다예) 과제 제출합니다. #44
Conversation
…기, AuthService 빈을 등록하기,AuthenticationPrincipalArgumentResolver를 빈 등록하고 authService에 대한 의존성을 주입하기
…빈 등록하고 authService에 대한 의존성을 주입하기
…ation을 하기 위한 클래스로 지정하기, ext-api.properties 파일을 활용하기 위한 설정 추가하기, ext-api.properties의 google.api.endpoint 값을 Environment를 사용해서 가져오기, 위 endpoint 값을 사용하여 GoogleMapsRestClient를 빈으로 등록하기
…le.api.endpoint 값을 어노테이션을 사용해서 가져오기, 위 endpoint 값을 사용하여 GoogleMapsRestClient를 빈으로 등록하기
…on을 하기 위한 클래스로 지정하기, application.properties의 security.jwt.token.secret-key 값을 활용하여 JwtTokenKeyProvider를 빈으로 등록하기
…만 InmemoryMessageRepository 빈이 등록되도록 설정하기, prod 프로파일일 때만 InmemoryMessageRepository 빈이 등록되도록 설정하기
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.
.
yohanii
left a comment
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.
잘 해결하셨네요!
|
|
||
| // TODO: Java-based Configuration을 하기 위한 클래스로 지정하기 | ||
| @Configuration | ||
| @ComponentScan(basePackages = "cholog.scan") |
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.
SpringCoreApplication.java에 @SpringBootApplication이 @componentscan을 들고 있어서,
여기엔 @componentscan이 필요 없습니다!
| public class ProfileConfig { | ||
|
|
||
| // TODO: dev 프로파일일 때만 InmemoryMessageRepository 빈이 등록되도록 설정하기 | ||
| @Bean("dataSource") |
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.
"dataSource"가 어떤 걸 의미하는지 궁금합니다!
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.
Readme 예시에서 이런 식으로 나와 있어 저도 꼭 적어야 하는건가? 하는 생각이었지만 찾아본 내용을 공유해드립니다!
@bean 어노테이션 괄호 안의 dataSource는 빈(bean)의 이름을 지정하기 위해 사용됩니다.
@bean 어노테이션에서 이름을 지정하지 않으면, 메서드 이름이 자동으로 빈의 이름으로 사용됩니다.
dataSource라는 이름을 사용하는 이유는 주로 데이터베이스와의 연결을 관리하는 빈이기 때문입니다
빈 이름을 동일하게 설정하는 이유는 환경별로 다른 구현체를 사용하되, 애플리케이션 코드에서는 일관된 방식으로 빈을 사용할 수 있도록 하기 위해서이다.
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.
오 그렇군요! 감사합니다!!
| @Value("${google.api.endpoint}") | ||
| private String googleApiEndpoint; |
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.
해당 방법도 좋고, parameter 안에 @value를 사용하는 법도 있습니다!
lxeso
left a comment
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.
고생하셨습니다! 잘하셨네요!
| @Configuration | ||
| public class AuthConfig { | ||
| // TODO: application.properties의 security.jwt.token.secret-key 값을 활용하여 JwtTokenKeyProvider를 빈으로 등록하기 | ||
| @Value("${security.jwt.token.secret-key}") |
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.
의존성 주입 부분에서 메서드 주입 방식이 아닌 필드 주입 방식을 쓰신 것 같은데 메서드 파라미터로 직접 값을 주입하는 방식이 코드의 의존성이 메서드 시그니처에 명시적으로 드러나게 되기 때문에 가독성과 의존성 관리를 위해서 메서드 주입 방식을 쓰시는 것도 좋을 듯합니다!
KimGyeongLock
left a comment
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 description provided.