팀 프로젝트에서 이번에 메인 브랜치에서 풀 받은 이후 빌드 오류는 없었지만 특정 부분에서 오류가 발생했다.
JPQL로 작성한 코드에서 id 필드를 찾을 수 없다고 되어있었다.
다른 팀원들은 정상 작동 하는데 나만 발생하는 오류였고 내가 팀원들과 다른 부분은 S3 이미지 처리를 위한 bucketConfig였다.
이미지를 NCP S3를 이용하여 불러와서 진행했는데, 기본 버킷과 테스트용 버킷으로 나눠 이미지 테스트를 할 수 있도록 코드가 작성 되어 있었다.
이 부분에서 이전에도 나만 오류가 발생하여 기본 버킷에 @Primary를 붙여 사용했었다.
@Primary
@Bean
public AmazonS3Client amazonS3Client() {
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey,secretKey);
return (AmazonS3Client) AmazonS3ClientBuilder
・ ・ ・
.build();
}
@Bean
public AmazonS3Client amazonS3TestClient() {
BasicAWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
return (AmazonS3Client) AmazonS3ClientBuilder
・ ・ ・
.build();
}
문제는 여기서 있었는데, 빌드를 IntelliJ 기본 빌드 툴로 사용하게 되면 타입으로 버킷을 불러오게 되어 같은 타입의 메소드가 두개이기 때문에 오류가 나는 것이었다.
Description:
Parameter 0 of constructor in com.ll.hype.global.s3.image.image.component.ImageComponent required a single bean, but 2 were found:
- amazonS3Client: defined by method 'amazonS3Client' in class path resource [**/s3/bucket/config/BucketConfig.class]
- amazonS3TestClient: defined by method 'amazonS3TestClient' in class path resource [**/s3/bucket/config/BucketConfig.class]
This may be due to missing parameter name information
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed
Gradle은 타입이 아닌 이름으로 불러오기 때문에 오류가 발생하지 않는 것이었다.