-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Closed
Labels
status: noteworthyA noteworthy issue to call out in the release notesA noteworthy issue to call out in the release notestype: enhancementA general enhancementA general enhancement
Milestone
Description
We've noticed that many applications are not using the validation features in web applications, while validator libraries on the classpath come with a cost.
We could do the following:
- remove the
spring-boot-starter-validation
dependency fromspring-boot-starter-web
andspring-boot-starter-webflux
- create a new
spring-boot-starter-validation-web
that brings in the validation dependencies without thetomcat-embed-el
which is currently excluded by the web starters - properly document that change in the release notes and the reference docs
PascalSchumacher, qrqhuang, ayoubAnbara, hackthur and albertocavalcante
Metadata
Metadata
Assignees
Labels
status: noteworthyA noteworthy issue to call out in the release notesA noteworthy issue to call out in the release notestype: enhancementA general enhancementA general enhancement
Type
Projects
Relationships
Development
Select code repository
Activity
bclozel commentedon Jan 10, 2020
We'll do the following:
spring-boot-starter-validation
fromspring-boot-starter-web
by defaultspring-boot-starter-validation
to useorg.glassfish:jakarta.el
instead of the current choice of default implementationWith this change, we don't need to add a new starter and we can consistently use the same el implementation.
ofabricio commentedon May 22, 2020
I'm surprised to figure out not most projects are not using validations, because all my web apps use them. I had to include this new starter.
I'm wondering what is people using instead?
bclozel commentedon May 22, 2020
The rationale behind this decision is not that most applications aren’t using validation, but rather that there is a significant amount of them and that the (startup and runtime) cost associated with the validation starter is far from negligible.
We usually try to strike the right balance between doing as much as possible with the developer’s intent and keeping setups efficient and lightweight. « Not all web applications should use validation and we want to optimize efficiency » is all that you should read into this decision.
springframeworkguru commentedon May 23, 2020
This change caught me by surprise a little bit. In upgrading to 2.3.0, I added the validation API, but not the hibernate impl. My unit tests started covering validation started to fail. Without test coverage, might not have caught this.
Maybe consider failing startup if the API is present, and impl is not?
11 remaining items
mykolap commentedon Jul 28, 2020
I don't know how to resolve it properly...
If validation starter is not used - put tomcat-el as a compile dependency to tomcat starter looks good.
But if validation starter is used - we will have 2 libs with el, from jakarta and tomcat, and it should be resolved by excluding one of them...
It doesn't look nice... I will think about better solution, now I see the only way manual resolving, that's what I did in my project...
hackthur commentedon Feb 18, 2021
Hi. In my case,
@Valid
not work, in GitHub repository specify that in the newest version of spring "Do not include the validation starter in web starters by default ". Now how can i use the validator@Valid
in the restcontrollersMy Pom.xml
My Entity class:
and my RestController class
wilkinsona commentedon Feb 18, 2021
A dependency on
spring-boot-starter-validation
should be sufficient. If that's not working and you'd like some help in figuring it out, please come and chat on Gitter or ask a question on Stack Overflow.jdriver2 commentedon Apr 16, 2021
what if you are using gradle? This tip is not working. springboot 2.4.4
wilkinsona commentedon Apr 16, 2021
@jdriver2 To which tip are you referring? The build system shouldn't make any difference and adding a dependency on
spring-boot-starter-validation
should be sufficient with both Maven and Gradle. As I said above, if that's not working and you'd like some help in figuring it out, please come and chat on Gitter or ask a question on Stack Overflow.jdriver2 commentedon Apr 16, 2021
i solved the issue. Using gradle, but required me to restart the IDE. Thanks!
@Valid
등이 포함된 javax.validation 패키지 spring-web-starter에 없는 문제 kyupid/java-chess-again#52avdept commentedon Apr 12, 2022
Wanted to point, if you use kotlin, you need to annotate your fields like
@field: NotNull @field:NotEmpty @field:NotBlank
, without it - validations won't work using kotlingabopushups commentedon May 19, 2022
@Arturo0911 Did you find a solution for your issue? I'm facing the same exact problem as you
141319nms commentedon Dec 5, 2022
i come with the same problem.i use the spring-boot-starter-parent v2.7.5,given the spring-boot-start-validation,but the validation never works,who has the answer ,please.
141319nms commentedon Dec 5, 2022
141319nms commentedon Dec 5, 2022
i get
bclozel commentedon Dec 5, 2022
Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.