Skip to content

Commit bf4cdce

Browse files
snicollwilkinsona
authored andcommitted
Create spring-boot-validation module
1 parent 51937c9 commit bf4cdce

File tree

39 files changed

+92
-60
lines changed

39 files changed

+92
-60
lines changed

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ include "spring-boot-project:spring-boot-tools:spring-boot-test-support"
8484
include "spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"
8585
include "spring-boot-project:spring-boot-tx"
8686
include "spring-boot-project:spring-boot-undertow"
87+
include "spring-boot-project:spring-boot-validation"
8788
include "spring-boot-system-tests:spring-boot-deployment-tests"
8889
include "spring-boot-system-tests:spring-boot-image-tests"
8990
include "spring-boot-tests:spring-boot-integration-tests:spring-boot-configuration-processor-tests"

spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ dependencies {
2929
optional(project(":spring-boot-project:spring-boot-reactor-netty"))
3030
optional(project(":spring-boot-project:spring-boot-tomcat"))
3131
optional(project(":spring-boot-project:spring-boot-undertow"))
32+
optional(project(":spring-boot-project:spring-boot-validation"))
3233
optional("ch.qos.logback:logback-classic")
3334
optional("org.apache.cassandra:java-driver-core") {
3435
exclude group: "org.slf4j", module: "jcl-over-slf4j"

spring-boot-project/spring-boot-actuator/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ dependencies {
3131
optional(project(":spring-boot-project:spring-boot-reactor-netty"))
3232
optional(project(":spring-boot-project:spring-boot-tomcat"))
3333
optional(project(":spring-boot-project:spring-boot-undertow"))
34+
optional(project(":spring-boot-project:spring-boot-validation"))
3435
optional("org.apache.cassandra:java-driver-core") {
3536
exclude group: "org.slf4j", module: "jcl-over-slf4j"
3637
}

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscovererTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,10 +31,10 @@
3131
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
3232
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
3333
import org.springframework.boot.autoconfigure.AutoConfigurations;
34-
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
3534
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
3635
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3736
import org.springframework.boot.test.context.runner.ContextConsumer;
37+
import org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration;
3838
import org.springframework.context.annotation.Configuration;
3939
import org.springframework.context.annotation.Import;
4040
import org.springframework.validation.annotation.Validated;

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/ServletEndpointDiscovererTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,10 +39,10 @@
3939
import org.springframework.boot.actuate.endpoint.web.EndpointServlet;
4040
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
4141
import org.springframework.boot.autoconfigure.AutoConfigurations;
42-
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
4342
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
4443
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
4544
import org.springframework.boot.test.context.runner.ContextConsumer;
45+
import org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration;
4646
import org.springframework.context.annotation.Configuration;
4747
import org.springframework.context.annotation.Import;
4848
import org.springframework.validation.annotation.Validated;

spring-boot-project/spring-boot-autoconfigure-all/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ dependencies {
5151
optional(project(":spring-boot-project:spring-boot-reactor-netty"))
5252
optional(project(":spring-boot-project:spring-boot-tomcat"))
5353
optional(project(":spring-boot-project:spring-boot-tx"))
54+
optional(project(":spring-boot-project:spring-boot-validation"))
5455
optional("co.elastic.clients:elasticsearch-java") {
5556
exclude group: "commons-logging", module: "commons-logging"
5657
}

spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2525
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
2626
import org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration;
27-
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
2827
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2928
import org.springframework.context.annotation.Bean;
3029
import org.springframework.context.annotation.Configuration;
@@ -39,7 +38,8 @@
3938
* @author Stephane Nicoll
4039
* @since 1.4.0
4140
*/
42-
@AutoConfiguration(after = { CouchbaseAutoConfiguration.class, ValidationAutoConfiguration.class })
41+
@AutoConfiguration(after = CouchbaseAutoConfiguration.class,
42+
afterName = "org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration")
4343
@ConditionalOnClass({ Bucket.class, CouchbaseRepository.class })
4444
@EnableConfigurationProperties(CouchbaseDataProperties.class)
4545
@Import({ CouchbaseDataConfiguration.class, CouchbaseClientFactoryConfiguration.class,

spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
3737
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders;
3838
import org.springframework.boot.autoconfigure.thread.Threading;
39-
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
40-
import org.springframework.boot.autoconfigure.validation.ValidatorAdapter;
4139
import org.springframework.boot.autoconfigure.web.ConditionalOnEnabledResourceChain;
4240
import org.springframework.boot.autoconfigure.web.ServerProperties;
4341
import org.springframework.boot.autoconfigure.web.WebProperties;
@@ -48,6 +46,7 @@
4846
import org.springframework.boot.autoconfigure.web.reactive.WebFluxProperties.Format;
4947
import org.springframework.boot.context.properties.EnableConfigurationProperties;
5048
import org.springframework.boot.convert.ApplicationConversionService;
49+
import org.springframework.boot.validation.autoconfigure.ValidatorAdapter;
5150
import org.springframework.boot.web.codec.CodecCustomizer;
5251
import org.springframework.boot.web.reactive.filter.OrderedHiddenHttpMethodFilter;
5352
import org.springframework.context.ApplicationContext;
@@ -106,8 +105,10 @@
106105
* @author Weix Sun
107106
* @since 2.0.0
108107
*/
109-
@AutoConfiguration(after = { CodecsAutoConfiguration.class, ReactiveMultipartAutoConfiguration.class,
110-
ValidationAutoConfiguration.class, WebSessionIdResolverAutoConfiguration.class })
108+
@AutoConfiguration(
109+
after = { CodecsAutoConfiguration.class, ReactiveMultipartAutoConfiguration.class,
110+
WebSessionIdResolverAutoConfiguration.class },
111+
afterName = "org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration")
111112
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
112113
@ConditionalOnClass(WebFluxConfigurer.class)
113114
@ConditionalOnMissingBean({ WebFluxConfigurationSupport.class })

spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
4545
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
4646
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProviders;
47-
import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration;
48-
import org.springframework.boot.autoconfigure.validation.ValidatorAdapter;
4947
import org.springframework.boot.autoconfigure.web.ConditionalOnEnabledResourceChain;
5048
import org.springframework.boot.autoconfigure.web.WebProperties;
5149
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
@@ -56,6 +54,7 @@
5654
import org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties.Format;
5755
import org.springframework.boot.context.properties.EnableConfigurationProperties;
5856
import org.springframework.boot.convert.ApplicationConversionService;
57+
import org.springframework.boot.validation.autoconfigure.ValidatorAdapter;
5958
import org.springframework.boot.web.servlet.ServletRegistrationBean;
6059
import org.springframework.boot.web.servlet.filter.OrderedFormContentFilter;
6160
import org.springframework.boot.web.servlet.filter.OrderedHiddenHttpMethodFilter;
@@ -142,8 +141,8 @@
142141
* @author Scott Frederick
143142
* @since 2.0.0
144143
*/
145-
@AutoConfiguration(after = { DispatcherServletAutoConfiguration.class, TaskExecutionAutoConfiguration.class,
146-
ValidationAutoConfiguration.class })
144+
@AutoConfiguration(after = { DispatcherServletAutoConfiguration.class, TaskExecutionAutoConfiguration.class },
145+
afterName = "org.springframework.boot.validation.autoconfigure.ValidationAutoConfiguration")
147146
@ConditionalOnWebApplication(type = Type.SERVLET)
148147
@ConditionalOnClass({ Servlet.class, DispatcherServlet.class, WebMvcConfigurer.class })
149148
@ConditionalOnMissingBean(WebMvcConfigurationSupport.class)
@@ -529,7 +528,9 @@ public FormattingConversionService mvcConversionService() {
529528
@Bean
530529
@Override
531530
public Validator mvcValidator() {
532-
if (!ClassUtils.isPresent("jakarta.validation.Validator", getClass().getClassLoader())) {
531+
if (!ClassUtils.isPresent("jakarta.validation.Validator", getClass().getClassLoader())
532+
|| !ClassUtils.isPresent("org.springframework.boot.validation.autoconfigure.ValidatorAdapter",
533+
getClass().getClassLoader())) {
533534
return super.mvcValidator();
534535
}
535536
return ValidatorAdapter.get(getApplicationContext(), getValidator());

spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring.factories

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ org.springframework.boot.autoconfigure.integration.IntegrationPropertiesEnvironm
44

55
# Background Preinitializers
66
org.springframework.boot.autoconfigure.preinitialize.BackgroundPreinitializer=\
7-
org.springframework.boot.autoconfigure.http.MessageConverterBackgroundPreinitializer,\
8-
org.springframework.boot.autoconfigure.validation.JakartaValidationBackgroundPreinitializer
7+
org.springframework.boot.autoconfigure.http.MessageConverterBackgroundPreinitializer
98

109
# Failure Analyzers
1110
org.springframework.boot.diagnostics.FailureAnalyzer=\

0 commit comments

Comments
 (0)