UnsatisfiedDependencyException 해결 (feat. ChatGTT)

byeol·2023년 5월 21일
0

제가 build.gradle에

  //Rest 요청을 위한 : spring이 client와 같은 역할
    implementation 'org.apache.httpcomponents:httpclient:4.5'

를 추가한 이후로 아래와 같은 오류가 발생했습니다.

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:Error creating bean with name 
's3Service' defined in file 
[D:\tool\merge_everyone\build\classes\java\main\com\everyonegarden\garden\s3\S3Servic
e.class]: Unsatisfied dependency expressed through constructor parameter 0; nested 
exception is org.springframework.beans.factory.BeanCreationException: Error creating 
bean with name 's3Client' defined in class path resource 
[com/everyonegarden/garden/s3/S3Config.class]: Bean instantiation via factory method 
failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [software.amazon.awssdk.services.s3.S3Client]: Factory method 
's3Client' threw exception; nested exception is java.lang.NoClassDefFoundError: 
org/apache/http/impl/client/DefaultClientConnectionReuseStrategy

위 오류를 그대로 읽어보면 일단 원하는 Bean이 제대로 등록되지 않았다는 의미인거 같습니다.
그래서 결국 ChatGPT에 물어보니

종속성이 올바르게 해결되고 있는지 확인하고 프로젝트의 다른 종속성과 호환되는 올바른 버전의 라이브러리를 지정해야한다고 합니다.

그래서 버전을 변경해주었습니다.

// before :  implementation 'org.apache.httpcomponents:httpclient:4.5'
implementation 'org.apache.httpcomponents:httpclient:4.5.7'

그러니 정상적으로 돌아갔습니다.
이번 일을 계기로 종속성을 올바르게 포함하고 있는지, 그리고 다른 종속성과 호환되는 올바른 버전인지도 확인해야 한다는 것을 처음 알게되었습니다.

profile
꾸준하게 Ready, Set, Go!

0개의 댓글