错误:找不到类型的验证程序:class

时间:2015-11-08 19:12:55

标签: java json spring rest spring-validator

我开始了一个新项目,我有一些问题需要验证我的请求。我发送了一个json对象,spring必须在端点使用之前对其进行验证。

Hier对象的类声明。

@Entity
@Table
public class A {
    @NotBlank
    @Column(columnDefinition = "TEXT", nullable = false)
    private B[] b;

B对象的结构:

    public class B {

    private String c;
    getter and setter ...

我在curl请求中发送的json对象的一部分

{
...
    "b" : [
        {"c": "abcdef"},
        {"c": "fedabc"}
    ]

包含请求映射的部分。端点必须使用json对象。

@RequestMapping(value = "/url", method = RequestMethod.POST, ..)
    public ResponseEntity<Movie> createMovie(@RequestBody @Valid A a) { ....

我遇到了这个例外:

[2015-11-08 19:55:26.817] boot - 19043 ERROR [http-nio-8080-exec-6] --- ErrorPageFilter: Forwarding to error page from request [/api/url] due to exception [HV000030: No validator could be found for type: class com.x.server.model.B[].]
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: class com.x.server.model.B[].
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.verifyResolveWasUnique(ConstraintValidatorManager.java:218)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.findMatchingValidatorClass(ConstraintValidatorManager.java:193)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.getInitializedValidator(ConstraintValidatorManager.java:97)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:125)
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91)
    at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:83)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:547)
    at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:487)
    at 

有任何想法 谢谢你的帮助。 欢呼声。

0 个答案:

没有答案