Spring Validation vs Hibernate Validation

前端 未结 2 1411
我在风中等你
我在风中等你 2021-02-07 04:47

I am confused between the two now. I know Hibernate Validator 6 is the reference implementation for Bean Validation 2.0 specs. It supports Grouping, Internationalization of er

2条回答
  •  盖世英雄少女心
    2021-02-07 05:28

    according to Spring Validation documentation

    With Bean Validation, a single javax.validation.Validator instance typically validates all model objects that declare validation constraints. To configure such a JSR-303 backed Validator with Spring MVC, simply add a Bean Validation provider, such as Hibernate Validator, to your classpath

    you can verify that by creating sample spring-boot project with spring-boot-starter-web dependency. It actually adds hibernate-validator dependency into your classpath

    Here are couple of links to jsr-303 in spring tutorials:

    1. https://howtodoinjava.com/spring/spring-mvc/spring-bean-validation-example-with-jsr-303-annotations/

    2. https://www.mkyong.com/spring-mvc/spring-3-mvc-and-jsr303-valid-example/

提交回复
热议问题