添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
小胡子的酱牛肉  ·  Make it easier to ...·  2 月前    · 
不羁的生姜  ·  一文搞定 Spring Data JPA ...·  2 月前    · 
高大的眼镜  ·  ClickHouse와 Spring ...·  1 月前    · 
旅行中的凉茶  ·  贡献 - Hibernate ...·  1 周前    · 
帅气的松球  ·  【译】使用select ...·  2 年前    · 
爱玩的小熊猫  ·  Let’s Encrypt ...·  2 年前    · 

Java – No validator could be found for constraint ‘javax.validation.constraints.NotBlank’ validating type ‘java.lang.String’

hibernate hibernate-validator java javax.validation validation

I'm using Hibernate validator to validate my beans.

Actually I have this dependencies on my POM

    <!-- Hibernate validator - Bean validation API Implementation -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>6.0.11.Final</version>
    </dependency>
    <!-- Verify validation annotations usage at compile time -->
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator-annotation-processor</artifactId>
        <version>6.0.11.Final</version>
    </dependency>
    <!-- Unified Expression Language - Spec -->
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>javax.el-api</artifactId>
        <version>3.0.1-b06</version>
    </dependency>
    <!-- Unified Expression Language - Implementation -->
    <dependency>
        <groupId>org.glassfish.web</groupId>
        <artifactId>javax.el</artifactId>
        <version>2.2.6</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>2.0.1.Final</version>
    </dependency>

And this a pice of my bean

import org.hibernate.annotations.ColumnDefault;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.Date;
public class Casa {
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    private Integer id;
    @Column(name="nomcaac") @NotBlank(message = "{casa.nomcaac.null}") @Size(min = 0, max = 300, message = "{casa.nomcaac.size}")
    private String nomcaac;

Now the problem comes when i try to validate my bean, i get this error message

No validator could be found for constraint
'javax.validation.constraints.NotBlank' validating type
'java.lang.String'. Check configuration for 'nomcaac'

I can't figure out whats my problem, I think I have the right dependencies according to this page.

@NotBlank is new in Bean Validation 2.0 so I suspect you have an old Hibernate Validator version (e.g. 5.x) in your classpath somehow.

You should check your dependency tree with mvn dependency:tree (and your webapp looking for an old jar).

By the way, your javax.el dependencies are incorrect: please refer to https://github.com/hibernate/hibernate-validator/#using-hibernate-validator for the correct one.