ConfigurationProperties中嵌套属性的java验证
当我想验证嵌套属性而不实例化它时,我不会得到任何非空性的异常
@ConfigurationProperties(prefix = "test")
@Component
@Getter
@Setter
@Validated
public class AllAppConfig {
@Valid
private NestedConfig nestedConfig;
}
但如果我像这样实例化它
NestedConfig nestedConfig=new NestedConfig();
我得到了正确的财产验证。有人能解释一下,为什么我需要实例化属性来正确验证它吗
在我的NestedConfig类下面
@Getter
@Setter
public class NestedConfig {
@NotNull
private String value;
}
共 (0) 个答案