-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MethodArgumentNotValidException from spring-web requires spring-context to compile #29182
Comments
Reading #23282 and #23486 we could consider it is expected, but I am wondering if we should differentiate optional Spring dependencies like here |
@sdeleuze I don't think this issue is related to the publishing of optional dependencies. This would not solve the point made by @Andrius-B as they still would get the compilation error in their project. @Andrius-B spring-web ships lots of support for optional dependencies and we can't add them explicitly for obvious reasons. The validation and binding features from spring-web are used in the context of spring-webmvc or spring-webflux, and they both have a mandatory dependency on spring-context. One would argue that those features are not mandatory for using, for example, Could you elaborate on the original use case you were working on when encountering this problem? |
Maybe this is a not-so-common use-case where we have a package-based build system (bazel). For each package we declare the compile time dependencies for the source files in that package. We found a couple of cases where Publishing the dependency as optional would indeed not fix our issue, but I initially thought this was an oversight and the issue should in fact be non-optional. Since @bclozel pointed out a case where the dependency is not needed, I will close this issue. |
Thanks for letting us know @Andrius-B |
Affects:
org.springframework:spring-web:5.3.23
Trying to update from
5.2
to5.3.23
lead us to an interesting issue, where a usage ofMethodArgumentNotValidException
would not compile. A minimal reproduction would be a gradle project as follows:excerpt from
build.gradle
:A java class:
This fails to compile with following error:
This is because
MethodArgumentNotValidException
(fromspring-web
) extendsorg.springframework.validation.BindException
(fromspring-context
), but thepom.xml
that gradle sees does not specify this compile time dependency: https://search.maven.org/artifact/org.springframework/spring-web/5.3.23/jarOnly
spring-beans
andspring-core
are specified as compile time dependencies (thus classes from these are present.)This change of
MethodArgumentNotValidException
extendingBindException
was discussed in issues #23107 #26219I think the correct behaviour here would be to mark
spring-context
as a compile time dependency forspring-web
as that would play along with various build systems better.The text was updated successfully, but these errors were encountered: