@Configuration
@ConfigurationProperties(prefix = "ncp.storage")
@Getter
@Setter
public class StorageConfig {
private String endpoint;
private String bucketname;
}
ncp에서 Object Storage에 저장된 파일 URL을 DB에 보다 간단하게 저장하기 위해
StorageConfig를 만들었는데 아래와 같은 에러가 발생
2025-02-24T22:52:17.587+09:00 ERROR 36520 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'ncp.storage' to com.patrol.global.storage.StorageConfig$$SpringCGLIB$$0:
Property: ncp.storage.bucketname
Value: "paw-patrol"
Origin: class path resource [application-secret.yml] - 49:17
Reason: java.lang.IllegalStateException: No setter found for property: bucketname
Action:
Update your application's configuration
Process finished with exit code 1
이 에러는 @ConfigurationProperties를 사용할 때 발생하는 일반적인 문제라고 한다.
Spring Boot가 properties/yml 파일의 값을 바인딩할 때
Java Bean 규약을 따르므로 setter 메서드가 필요하기 때문에 발생
1. @Setter 추가
2. 생성자 바인딩 사용
두 가지 해결 방법이 있는데 1번 방법을 사용했다.
이미 Lombok을 사용하고 있었기 때문에 보다 간단한 방법을 선택하여 해결했다!
| Spring Boot에서 @ModelAttribute와 폼 데이터 바인딩 문제 (0) | 2025.02.25 |
|---|---|
| 소셜 로그인시 브라우저에 accessToken 토큰이 발행되지 않음 (0) | 2025.02.24 |
| VmmemWSL 메모리 과잉 할당 문제 (0) | 2025.02.13 |
| Logstash와 MySQL 연결 에러 (0) | 2025.02.11 |
| 채팅방에 처음 입장시 읽지 않은 메시지가 정상적으로 출력되지 않았던 문제 (1) | 2025.02.06 |