ConversionNotSupportedException
2022, Mar 27
java8 annotation
error log
expressed through field ‘expirations’; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type ‘java.lang.String’ to required type ‘java.util.List’; nested exception is java.lang.IllegalStateException:
Cannot convert value of type ‘java.lang.String’ to required type ‘DeviceExpiration’:
no matching editors or conversion strategy found
설정yml
login:
expirations:
- device: pc
limit: 5
- device: mobile
limit: 1440
- device: tablet
limit: 1440
cause
@Value("${login.expirations:}")
private List<DeviceExpiration> expirations;
solution
To mapping Object, using @ConfigurationProperties
로 선언해야한다.
@Getter
@Component
@ConfigurationProperties("login")
public class ExpirationConfig {
private List<DeviceExpiration> expirations;
public void setExpirations(List<DeviceExpiration> expirations) {
this.expirations = expirations;
}
}
이렇게 하니 된다