5

I have a Spring boot application. My request classes passed to my @RestController contains javax.validation annotations which I cannot change/remove - they come as a 3rd party library. So I want to validate my request objects manually or don't validate them at all. Unfortunately if I add either:

  • spring-boot-starter-validation - to have Validator bean preconfigured or
  • validation-api and hibernate-validator - to create a Validator by myself

Spring automatically enables validation for all my @RestControllers.

Is it possible to disable automatic validation in Spring?

zolv
  • 1,720
  • 2
  • 19
  • 36
  • 2
    could you disable the auto configuration of `ValidationAutoConfiguration`? This can be done with `@EnableAutoConfiguration(exclude = ValidationAutoConfiguration.class)` – Michael McFadyen Oct 13 '20 at 21:30
  • 1
    Does this answer your question? [How to disable Hibernate validation in a Spring Boot project](https://stackoverflow.com/questions/26764532/how-to-disable-hibernate-validation-in-a-spring-boot-project) – ℛɑƒæĿᴿᴹᴿ Oct 13 '20 at 23:56
  • 1
    spring.jpa.properties.javax.persistence.validation.mode=none – ℛɑƒæĿᴿᴹᴿ Oct 13 '20 at 23:57

0 Answers0