Java/오류노트
[Java/오류노트] Solved - Spring Boot Configuration Processor : java.lang.IllegalStateException: No setter found for property 해결방법
adjh54
2025. 2. 4. 20:01
728x170
해당 글에서는 Spring Boot Configuration Processor에서 발생하는 java.lang.IllegalStateException: No setter found for property 오류에 대해 알아봅니다.
1) 문제점
💡 문제점
- @ConfigurationProperties(prefix = "keycloak") 이라는 properties 파일을 만들어서 일괄적으로 설정 파일들을 가져오려는 도중에 아래와 같은 오류를 맞이하였습니다.
- java.lang.IllegalStateException: No setter found for property: auth-server-url

1. 문제 구성 파일 확인
💡 아래와 같이 Keycloak Properties를 yml 파일 형태로 지정하였습니다.
keycloak:
auth-server-url: http://localhost:9001
realm: dev-realm
client-id: spring-boot-app
client-secret: z4q0ONegiuXAt4lMCUwFUqh27172DYnf
url:
get-token-url: /protocol/openid-connect/token
💡 아래와 같이 @ConfigurationProperties 속성을 통해서 keycloak으로 시작하는 파일정보를 객체로 매핑하여서 데이터를 가져오려구 구성했습니다.
package com.blog.springbootkeycloak.config.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Please explain the class!!
*
* @author : jonghoon
* @fileName : KeycloakProperties
* @since : 25. 1. 25.
*/
@Getter
@ConfigurationProperties(prefix = "keycloak")
public class KeycloakProperties {
private String authServerUrl;
private String realm;
private String clientId;
private String clientSecret;
@Getter
public static class url {
private String getTokenUrl;
}
}
2) 해결방법
💡 해결방법
- 위에 와 같이 파일 데이터는 정상적으로 가져왔지만, No setter found for property로 @Setter 어노테이션이 없기에 발생하는 문제였습니다.
- properties 파일의 값을 바인딩할 때 Java Bean 규약을 따르므로, setter 메서드가 반드시 필요합니다.
💡 [참고] Spring Boot Configuration Processor에 대해 궁금하시면 아래의 글을 참고하시면 도움이 됩니다.
[Java] Spring Boot Configuration Processor 활용하기 : 외부 설정 파일(yaml/yml, properties) 불러오기
해당 글에서는 Spring Boot Configuration Processor를 활용하여서 외부 설정 소스 파일(yaml/yml, properties)을 불러오는 다양한 방법에 대해 알아봅니다 1) spring-boot-configuration-processor💡 spring-boot-configuration-
adjh54.tistory.com
1. 해결방법 1 : 클래스 레벨에 @Setter 추가
💡 해결방법 1 : 클래스 레벨에 @Setter 추가
- 아래와 같이 클래스 레벨에 추가를 해주었습니다.
package com.blog.springbootkeycloak.config.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Please explain the class!!
*
* @author : jonghoon
* @fileName : KeycloakProperties
* @since : 25. 1. 25.
*/
@Getter
@Setter
@ConfigurationProperties(prefix = "keycloak")
public class KeycloakProperties {
private String authServerUrl;
private String realm;
private String clientId;
private String clientSecret;
@Setter
@Getter
public static class url {
private String getTokenUrl;
}
}
2. 해결방법 2: 필드에 대한 Setter를 구현합니다
💡 해결방법 2: 필드에 대한 Setter를 구현합니다
- 각각 필드에 대해서 생성자를 구현하여서 이를 대체하였습니다.
package com.blog.springbootkeycloak.config.properties;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* Please explain the class!!
*
* @author : jonghoon
* @fileName : KeycloakProperties
* @since : 25. 1. 25.
*/
@Getter
@ConfigurationProperties(prefix = "keycloak")
public class KeycloakProperties {
private String authServerUrl;
private String realm;
private String clientId;
private String clientSecret;
@Getter
public static class url {
private String getTokenUrl;
public url(String getTokenUrl) {
this.getTokenUrl = getTokenUrl;
}
}
public KeycloakProperties(String authServerUrl, String realm, String clientId, String clientSecret) {
this.authServerUrl = authServerUrl;
this.realm = realm;
this.clientId = clientId;
this.clientSecret = clientSecret;
}
}
3) 결과 확인
💡 결과 확인
- 결과적으로 해당 문제가 해결되어서 잘 수행됨을 확인하였습니다.


오늘도 감사합니다 😀
그리드형