properties 를 참조하지 못해 발생한 오류

김형준 Kim Hyeong Jun·2022년 12월 29일
1

로컬 환경에서는 잘 작동하던 서버가,
원격 환경(AWS EC2)에 올리니 에러가 뜨며 작동하지 않았다.

아래는 에러의 내용 중 일부이다!

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder ‘kakao.client.id’ in value “${kakao.client.id}”
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘kakaoService’: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve pla ceholder ‘kakao.client.id’ in value “${kakao.client.id}”
springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userController’ defined in file [/Users/kimhyeongjun/Desktop/ideaProjects/hanghae-BnB/build/classes/java/main/com/hanghae/hanghaebnb/users/controller/UserController.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘kakaoService’: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder ‘kakao.client.id’ in value “${kakao.client.id}”

3가지의 에러 문구에서 공통적으로 보이는게 “${kakao.client.id}” 라는 부분이었다.


위의 부분에서 아래에 있는 리소스 내부의 파일에 들어가 값을 못 찾아온다는 오류라고 판단이 되었다.

그럼 왜 로컬에서는 값이 잘 파싱되서 작동을 했는데,
서버에서는 제대로 파싱을 못했을까?

확실한 이유는 찾지 못했지만,
.gitignore 로 관리되는 파일이라 CODE DEPLOY 에서 CI/CD 가 돌아가면서 시크릿 파일으로 암호화된 파일을 제대로 못 불러오는거라고 생각한다.

위와 같은 생각을 하고, application.properties 에서 include 된 파일을 찾아보니 kakao 가 빠져 있었고, 이를 추가해주니 서버에서도 정상적으로 작동을 하였다!

로컬에서 작동이 잘 됐다?
인텔리제이가 똑똑하게 알아서 파일을 뒤져서 값을 찾아준걸까?
서버에서 작동을 안 됐다?
인텔리제이가 알아서 해주던 작업을 서버에서는 해주지 못했던게 아닐까?

profile
I want be a developer🙂

0개의 댓글