binchoo / spring-boot-210523

스프링 부트와 AWS로 혼자 구현하는 웹 서비스 정독하기
0 stars 0 forks source link

[런타임 오류] 'ClientRegistrationRepository' that could not be found. #17

Closed binchoo closed 3 years ago

binchoo commented 3 years ago

챕터: #12

[이슈 내용] Application 실행 시, ClientRegistrationRepository 빈 주입을 받을 수 없다고 함.

***************************
APPLICATION FAILED TO START
***************************

Description:

Method springSecurityFilterChain in org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration required a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' that could not be found.

Action:

Consider defining a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' in your configuration.

> Task :Application.main() FAILED

Execution failed for task ':Application.main()'.
> Process 'command 'C:/Program Files/Java/jdk-13.0.2/bin/java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

[이슈 원인] 의심: .gitignore에 의해 application-oauth.properties가 지금 컴퓨터에 없기 때문에?

binchoo commented 3 years ago

연관 이슈: https://github.com/jojoldu/freelec-springboot2-webservice/issues/253

[이슈 원인] https://github.com/binchoo/spring-boot-210523/issues/17#issue-915009011 에 언급한 바와 같이, application-oauth.properties 내용이 없었기 때문

[특이 사항] 해당 원인 해결을 위해 당연히 oauth 설정 파일을 추가하였으나 몇 시간 동안 스프링이 시동되지 않았다.

다음 절차로 해결하였다.

  1. SecurityConfig: WebSecurityConfigurerAdapter 클래스의 필드로 ClientRegistrationRepository 객체를 하나 선언하여 빈 주입을 의도한다.
  2. 서버를 실행한다. 여전히 https://github.com/binchoo/spring-boot-210523/issues/17#issue-915009011과 동일한 오류를 만난다.
  3. 실행하고 보니, application-oauth.properties 내용이 완전 초기화가 되었다!?
  4. 설정 파일에 다시 구글 OAuth2 인증정보를 작성해 넣었다..
  5. 서버 실행이 정상적으로 진행되었다....