에러메세지:
com.amazonaws.SdkClientException: Failed to connect to service endpoint:
at com.amazonaws.internal.EC2ResourceFetcher.doReadResource(EC2ResourceFetcher.java:100) ~[aws-java-sdk-core-1.11.792.jar:na]
이유:aws sdk 에러가 나는 이유는, build.gradle에, spring-cloud-starter-aws 의존성 주입시 로컬환경은, aws환경이 아니기때문에 나는 에러라고 한다.
해결: amazon EC2가 아닌 환경의 시스템 환경변수를 만들어 주는 것
[run]-[configuration]
vm option에 아래 문장 추가
-Dcom.amazonaws.sdk.disableEc2Metadata=true
에러메세지:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name
'org.springframework.cloud.aws.core.env.ResourceIdResolver.BEAN_NAME':
Invocation of init method failed;
이유: stack.auto
Spring Cloud 실행 시, 서버 구성을 자동화하는 CloudFormation이 자동으로 실행되는데 이를 사용하지 않겠다는 설정입니다.
해당 설정을 안해주면 아래의 에러가 발생합니다.
해결: stack:
auto: false
aws 연결하는 과정에서 추천되는 플러그인 : Suggested plugins AWS Toolkit, Big Data Tools, Spring WebSocket
에러메세지:
com.amazonaws.SdkClientException: Unable to load AWS credentials from any provider in the chain:
[com.amazonaws.auth.EC2ContainerCredentialsProviderWrapper@678c96e3: Failed to connect to service endpoint: ,
com.amazonaws.auth.profile.ProfileCredentialsProvider@30e50936: profile file cannot be null]
에러메세지:
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 's3config': Injection of autowired dependencies failed;
nested exception is java.lang.IllegalArgumentException:
Could not resolve placeholder 'cloud.aws.credentials.access-key' in value "${cloud.aws.credentials.access-key}"
이유: 여러가지 시도해본 결과 git ignore에 따로 빼둔 엑세스키, 시크릿키를 import해오지 않아서 생긴 문제였다.
해결: application.yml에 config import 추가
spring:
config:
import: application-aws.yml
에러메세지:
Error resolving template [test], template might not exist or might not be accessible by any of the configured Template Resolvers
이유: 컨트롤러에서 return값이 template 파일명과 동일하지 않아서 생긴 문제.
해결: 컨트롤러 return 값과 파일명을 동일하게 해줌.
에러메세지:
Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=--------------------------362236057118211232888890;charset=UTF-8' not supported]
상황: image 파일을 받게되면서 postman에서 json-row형식이 아니라 form-data로 받는 과정에서 뜬 오류
해결: @RequestBody는 json으로 들어오는 바디 데이터를 파싱해주는 것 이기 때문에 제거 -> @RequestPart로 변경