Create spring-boot-http-client module

This commit is contained in:
Andy Wilkinson 2025-05-06 17:51:50 +01:00
parent c474b4bbb8
commit 5c90bf9fc3
59 changed files with 271 additions and 194 deletions

View File

@ -77,6 +77,7 @@ include "spring-boot-project:spring-boot-h2console"
include "spring-boot-project:spring-boot-hateoas" include "spring-boot-project:spring-boot-hateoas"
include "spring-boot-project:spring-boot-hazelcast" include "spring-boot-project:spring-boot-hazelcast"
include "spring-boot-project:spring-boot-http" include "spring-boot-project:spring-boot-http"
include "spring-boot-project:spring-boot-http-client"
include "spring-boot-project:spring-boot-http-codec" include "spring-boot-project:spring-boot-http-codec"
include "spring-boot-project:spring-boot-integration" include "spring-boot-project:spring-boot-integration"
include "spring-boot-project:spring-boot-integration-tests" include "spring-boot-project:spring-boot-integration-tests"

View File

@ -41,6 +41,7 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-flyway")) optional(project(":spring-boot-project:spring-boot-flyway"))
optional(project(":spring-boot-project:spring-boot-hazelcast")) optional(project(":spring-boot-project:spring-boot-hazelcast"))
optional(project(":spring-boot-project:spring-boot-http")) optional(project(":spring-boot-project:spring-boot-http"))
optional(project(":spring-boot-project:spring-boot-http-client"))
optional(project(":spring-boot-project:spring-boot-http-codec")) optional(project(":spring-boot-project:spring-boot-http-codec"))
optional(project(":spring-boot-project:spring-boot-integration")) optional(project(":spring-boot-project:spring-boot-integration"))
optional(project(":spring-boot-project:spring-boot-jackson")) optional(project(":spring-boot-project:spring-boot-jackson"))

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,8 +31,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration; import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -52,8 +50,11 @@ import org.springframework.core.annotation.Order;
* @author Moritz Halbritter * @author Moritz Halbritter
* @since 3.0.0 * @since 3.0.0
*/ */
@AutoConfiguration(after = { ObservationAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class, @AutoConfiguration(
RestTemplateAutoConfiguration.class, WebClientAutoConfiguration.class, RestClientAutoConfiguration.class }) after = { ObservationAutoConfiguration.class, CompositeMeterRegistryAutoConfiguration.class,
WebClientAutoConfiguration.class },
afterName = { "org.springframework.boot.http.client.rest.autoconfigure.RestClientAutoConfiguration",
"org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration" })
@ConditionalOnClass(Observation.class) @ConditionalOnClass(Observation.class)
@ConditionalOnBean(ObservationRegistry.class) @ConditionalOnBean(ObservationRegistry.class)
@Import({ RestTemplateObservationConfiguration.class, WebClientObservationConfiguration.class, @Import({ RestTemplateObservationConfiguration.class, WebClientObservationConfiguration.class,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import; import org.springframework.context.annotation.Import;
@ -39,7 +38,7 @@ import org.springframework.context.annotation.Import;
* @author Moritz Halbritter * @author Moritz Halbritter
* @since 3.0.0 * @since 3.0.0
*/ */
@AutoConfiguration(after = RestTemplateAutoConfiguration.class) @AutoConfiguration(afterName = "org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration")
@ConditionalOnClass(Encoding.class) @ConditionalOnClass(Encoding.class)
@Import({ SenderConfiguration.class, BraveConfiguration.class, OpenTelemetryConfiguration.class }) @Import({ SenderConfiguration.class, BraveConfiguration.class, OpenTelemetryConfiguration.class })
@EnableConfigurationProperties(ZipkinProperties.class) @EnableConfigurationProperties(ZipkinProperties.class)

View File

@ -39,8 +39,8 @@ import org.springframework.boot.actuate.endpoint.web.WebOperation;
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate; import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration; import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext; import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;

View File

@ -31,8 +31,8 @@ import org.springframework.boot.actuate.health.HealthComponent;
import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration; import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;

View File

@ -30,8 +30,8 @@ import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagem
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration; import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration; import org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration; import org.springframework.boot.security.autoconfigure.servlet.SecurityAutoConfiguration;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;

View File

@ -47,8 +47,8 @@ import org.springframework.boot.actuate.autoconfigure.observation.web.client.Htt
import org.springframework.boot.actuate.autoconfigure.observation.web.reactive.WebFluxObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.web.reactive.WebFluxObservationAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.web.servlet.WebMvcObservationAutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration; import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
import org.springframework.boot.actuate.metrics.web.client.ObservationRestClientCustomizer; import org.springframework.boot.actuate.metrics.web.client.ObservationRestClientCustomizer;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; import org.springframework.boot.http.client.rest.autoconfigure.RestClientAutoConfiguration;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.CapturedOutput;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration; import org.springframework.boot.http.client.rest.autoconfigure.RestClientAutoConfiguration;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.test.system.OutputCaptureExtension;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
import org.springframework.boot.actuate.metrics.web.client.ObservationRestTemplateCustomizer; import org.springframework.boot.actuate.metrics.web.client.ObservationRestTemplateCustomizer;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.CapturedOutput;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration; import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext; import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.system.OutputCaptureExtension; import org.springframework.boot.test.system.OutputCaptureExtension;

View File

@ -25,8 +25,8 @@ import org.springframework.boot.actuate.autoconfigure.observation.web.client.Htt
import org.springframework.boot.actuate.autoconfigure.tracing.BraveAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.tracing.BraveAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.tracing.MicrometerTracingAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.tracing.MicrometerTracingAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration; import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration;
import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration;
import org.springframework.boot.test.context.assertj.ApplicationContextAssertProvider; import org.springframework.boot.test.context.assertj.ApplicationContextAssertProvider;
import org.springframework.boot.test.context.runner.AbstractApplicationContextRunner; import org.springframework.boot.test.context.runner.AbstractApplicationContextRunner;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;

View File

@ -1,102 +0,0 @@
/*
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.http.client;
import java.time.Duration;
import org.springframework.boot.http.client.HttpClientSettings;
import org.springframework.boot.http.client.HttpRedirects;
/**
* Abstract base class for properties that directly or indirectly make use of a blocking
* or reactive HTTP client.
*
* @author Phillip Webb
* @since 3.5.0
* @see HttpClientSettings
*/
public abstract class AbstractHttpClientProperties {
/**
* Handling for HTTP redirects.
*/
private HttpRedirects redirects;
/**
* Default connect timeout for a client HTTP request.
*/
private Duration connectTimeout;
/**
* Default read timeout for a client HTTP request.
*/
private Duration readTimeout;
/**
* Default SSL configuration for a client HTTP request.
*/
private final Ssl ssl = new Ssl();
public HttpRedirects getRedirects() {
return this.redirects;
}
public void setRedirects(HttpRedirects redirects) {
this.redirects = redirects;
}
public Duration getConnectTimeout() {
return this.connectTimeout;
}
public void setConnectTimeout(Duration connectTimeout) {
this.connectTimeout = connectTimeout;
}
public Duration getReadTimeout() {
return this.readTimeout;
}
public void setReadTimeout(Duration readTimeout) {
this.readTimeout = readTimeout;
}
public Ssl getSsl() {
return this.ssl;
}
/**
* SSL configuration.
*/
public static class Ssl {
/**
* SSL bundle to use.
*/
private String bundle;
public String getBundle() {
return this.bundle;
}
public void setBundle(String bundle) {
this.bundle = bundle;
}
}
}

View File

@ -16,10 +16,11 @@
package org.springframework.boot.autoconfigure.http.client.reactive; package org.springframework.boot.autoconfigure.http.client.reactive;
import java.time.Duration;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.springframework.boot.autoconfigure.http.client.AbstractHttpClientProperties;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.http.client.HttpRedirects;
import org.springframework.boot.http.client.reactive.ClientHttpConnectorBuilder; import org.springframework.boot.http.client.reactive.ClientHttpConnectorBuilder;
import org.springframework.boot.http.client.reactive.ClientHttpConnectorSettings; import org.springframework.boot.http.client.reactive.ClientHttpConnectorSettings;
import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ClientHttpConnector;
@ -32,13 +33,61 @@ import org.springframework.http.client.reactive.ClientHttpConnector;
* @since 3.5.0 * @since 3.5.0
* @see ClientHttpConnectorSettings * @see ClientHttpConnectorSettings
*/ */
public abstract class AbstractClientHttpConnectorProperties extends AbstractHttpClientProperties { public abstract class AbstractClientHttpConnectorProperties {
/**
* Handling for HTTP redirects.
*/
private HttpRedirects redirects;
/**
* Default connect timeout for a client HTTP request.
*/
private Duration connectTimeout;
/**
* Default read timeout for a client HTTP request.
*/
private Duration readTimeout;
/**
* Default SSL configuration for a client HTTP request.
*/
private final Ssl ssl = new Ssl();
/** /**
* Default connector used for a client HTTP request. * Default connector used for a client HTTP request.
*/ */
private Connector connector; private Connector connector;
public HttpRedirects getRedirects() {
return this.redirects;
}
public void setRedirects(HttpRedirects redirects) {
this.redirects = redirects;
}
public Duration getConnectTimeout() {
return this.connectTimeout;
}
public void setConnectTimeout(Duration connectTimeout) {
this.connectTimeout = connectTimeout;
}
public Duration getReadTimeout() {
return this.readTimeout;
}
public void setReadTimeout(Duration readTimeout) {
this.readTimeout = readTimeout;
}
public Ssl getSsl() {
return this.ssl;
}
public Connector getConnector() { public Connector getConnector() {
return this.connector; return this.connector;
} }
@ -47,6 +96,26 @@ public abstract class AbstractClientHttpConnectorProperties extends AbstractHttp
this.connector = connector; this.connector = connector;
} }
/**
* SSL configuration.
*/
public static class Ssl {
/**
* SSL bundle to use.
*/
private String bundle;
public String getBundle() {
return this.bundle;
}
public void setBundle(String bundle) {
this.bundle = bundle;
}
}
/** /**
* Supported factory types. * Supported factory types.
*/ */

View File

@ -22,8 +22,8 @@ import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.http.client.AbstractHttpClientProperties.Ssl;
import org.springframework.boot.autoconfigure.http.client.reactive.AbstractClientHttpConnectorProperties.Connector; import org.springframework.boot.autoconfigure.http.client.reactive.AbstractClientHttpConnectorProperties.Connector;
import org.springframework.boot.autoconfigure.http.client.reactive.AbstractClientHttpConnectorProperties.Ssl;
import org.springframework.boot.http.client.HttpRedirects; import org.springframework.boot.http.client.HttpRedirects;
import org.springframework.boot.http.client.reactive.ClientHttpConnectorBuilder; import org.springframework.boot.http.client.reactive.ClientHttpConnectorBuilder;
import org.springframework.boot.http.client.reactive.ClientHttpConnectorSettings; import org.springframework.boot.http.client.reactive.ClientHttpConnectorSettings;

View File

@ -1,7 +1,4 @@
org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration
org.springframework.boot.autoconfigure.http.client.reactive.ClientHttpConnectorAutoConfiguration org.springframework.boot.autoconfigure.http.client.reactive.ClientHttpConnectorAutoConfiguration
org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfiguration org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration
org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration org.springframework.boot.autoconfigure.web.servlet.HttpEncodingAutoConfiguration

View File

@ -2049,6 +2049,7 @@ bom {
"spring-boot-hateoas", "spring-boot-hateoas",
"spring-boot-hazelcast", "spring-boot-hazelcast",
"spring-boot-http", "spring-boot-http",
"spring-boot-http-client",
"spring-boot-http-codec", "spring-boot-http-codec",
"spring-boot-integration", "spring-boot-integration",
"spring-boot-jackson", "spring-boot-jackson",

View File

@ -85,6 +85,7 @@ dependencies {
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-http", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-http", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-http-client", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-http-codec", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-http-codec", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-integration", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-integration", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata")) autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata"))
@ -165,6 +166,7 @@ dependencies {
configurationProperties(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-hateoas", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-http", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-http", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-http-client", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-http-codec", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-http-codec", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-integration", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-integration", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata")) configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata"))
@ -221,6 +223,7 @@ dependencies {
implementation(project(path: ":spring-boot-project:spring-boot-devtools")) implementation(project(path: ":spring-boot-project:spring-boot-devtools"))
implementation(project(path: ":spring-boot-project:spring-boot-docker-compose")) implementation(project(path: ":spring-boot-project:spring-boot-docker-compose"))
implementation(project(path: ":spring-boot-project:spring-boot-http")) implementation(project(path: ":spring-boot-project:spring-boot-http"))
implementation(project(path: ":spring-boot-project:spring-boot-http-client"))
implementation(project(path: ":spring-boot-project:spring-boot-http-codec")) implementation(project(path: ":spring-boot-project:spring-boot-http-codec"))
implementation(project(path: ":spring-boot-project:spring-boot-integration")) implementation(project(path: ":spring-boot-project:spring-boot-integration"))
implementation(project(path: ":spring-boot-project:spring-boot-jackson")) implementation(project(path: ":spring-boot-project:spring-boot-jackson"))

View File

@ -158,9 +158,9 @@ TIP: You can also change the xref:io/rest-client.adoc#io.rest-client.clienthttpr
[[io.rest-client.restclient.ssl]] [[io.rest-client.restclient.ssl]]
=== RestClient SSL Support === RestClient SSL Support
If you need custom SSL configuration on the javadoc:org.springframework.http.client.ClientHttpRequestFactory[] used by the javadoc:org.springframework.web.client.RestClient[], you can inject a javadoc:org.springframework.boot.autoconfigure.web.client.RestClientSsl[] instance that can be used with the builder's `apply` method. If you need custom SSL configuration on the javadoc:org.springframework.http.client.ClientHttpRequestFactory[] used by the javadoc:org.springframework.web.client.RestClient[], you can inject a javadoc:org.springframework.boot.http.client.rest.autoconfigure.RestClientSsl[] instance that can be used with the builder's `apply` method.
The javadoc:org.springframework.boot.autoconfigure.web.client.RestClientSsl[] interface provides access to any xref:features/ssl.adoc#features.ssl.bundles[SSL bundles] that you have defined in your `application.properties` or `application.yaml` file. The javadoc:org.springframework.boot.http.client.rest.autoconfigure.RestClientSsl[] interface provides access to any xref:features/ssl.adoc#features.ssl.bundles[SSL bundles] that you have defined in your `application.properties` or `application.yaml` file.
The following code shows a typical example: The following code shows a typical example:

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.docs.io.restclient.restclient.ssl; package org.springframework.boot.docs.io.restclient.restclient.ssl;
import org.springframework.boot.autoconfigure.web.client.RestClientSsl; import org.springframework.boot.http.client.rest.autoconfigure.RestClientSsl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClient;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,7 @@ package org.springframework.boot.docs.io.restclient.resttemplate.customization;
import java.time.Duration; import java.time.Duration;
import org.springframework.boot.autoconfigure.web.client.RestTemplateBuilderConfigurer; import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateBuilderConfigurer;
import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2023 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,8 @@
package org.springframework.boot.docs.io.restclient.restclient.ssl package org.springframework.boot.docs.io.restclient.restclient.ssl
import org.springframework.boot.autoconfigure.web.client.RestClientSsl
import org.springframework.boot.docs.io.restclient.restclient.ssl.settings.Details import org.springframework.boot.docs.io.restclient.restclient.ssl.settings.Details
import org.springframework.boot.http.client.rest.autoconfigure.RestClientSsl
import org.springframework.stereotype.Service import org.springframework.stereotype.Service
import org.springframework.web.client.RestClient import org.springframework.web.client.RestClient

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2022 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@
package org.springframework.boot.docs.io.restclient.resttemplate.customization package org.springframework.boot.docs.io.restclient.resttemplate.customization
import org.springframework.boot.autoconfigure.web.client.RestTemplateBuilderConfigurer import org.springframework.boot.http.client.rest.autoconfigure.RestTemplateBuilderConfigurer
import org.springframework.boot.web.client.RestTemplateBuilder import org.springframework.boot.web.client.RestTemplateBuilder
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration

View File

@ -0,0 +1,27 @@
plugins {
id "java-library"
id "org.springframework.boot.auto-configuration"
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.deployed"
id "org.springframework.boot.optional-dependencies"
}
description = "Spring Boot HTTP Client"
dependencies {
api(project(":spring-boot-project:spring-boot"))
implementation(project(":spring-boot-project:spring-boot-http"))
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
optional("io.projectreactor.netty:reactor-netty-http")
optional("org.apache.httpcomponents.client5:httpclient5")
optional("org.eclipse.jetty:jetty-client")
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("jakarta.servlet:jakarta.servlet-api")
testRuntimeOnly("org.springframework:spring-webflux")
}

View File

@ -14,13 +14,15 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import java.time.Duration;
import java.util.function.Supplier; import java.util.function.Supplier;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
import org.springframework.boot.http.client.HttpRedirects;
import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpRequestFactory;
/** /**
@ -28,16 +30,64 @@ import org.springframework.http.client.ClientHttpRequestFactory;
* {@link ClientHttpRequestFactory}. * {@link ClientHttpRequestFactory}.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 3.5.0 * @since 4.0.0
* @see ClientHttpRequestFactorySettings * @see ClientHttpRequestFactorySettings
*/ */
public abstract class AbstractHttpRequestFactoryProperties extends AbstractHttpClientProperties { public abstract class AbstractHttpRequestFactoryProperties {
/**
* Handling for HTTP redirects.
*/
private HttpRedirects redirects;
/**
* Default connect timeout for a client HTTP request.
*/
private Duration connectTimeout;
/**
* Default read timeout for a client HTTP request.
*/
private Duration readTimeout;
/**
* Default SSL configuration for a client HTTP request.
*/
private final Ssl ssl = new Ssl();
/** /**
* Default factory used for a client HTTP request. * Default factory used for a client HTTP request.
*/ */
private Factory factory; private Factory factory;
public HttpRedirects getRedirects() {
return this.redirects;
}
public void setRedirects(HttpRedirects redirects) {
this.redirects = redirects;
}
public Duration getConnectTimeout() {
return this.connectTimeout;
}
public void setConnectTimeout(Duration connectTimeout) {
this.connectTimeout = connectTimeout;
}
public Duration getReadTimeout() {
return this.readTimeout;
}
public void setReadTimeout(Duration readTimeout) {
this.readTimeout = readTimeout;
}
public Ssl getSsl() {
return this.ssl;
}
public Factory getFactory() { public Factory getFactory() {
return this.factory; return this.factory;
} }
@ -46,6 +96,26 @@ public abstract class AbstractHttpRequestFactoryProperties extends AbstractHttpC
this.factory = factory; this.factory = factory;
} }
/**
* SSL configuration.
*/
public static class Ssl {
/**
* SSL bundle to use.
*/
private String bundle;
public String getBundle() {
return this.bundle;
}
public void setBundle(String bundle) {
this.bundle = bundle;
}
}
/** /**
* Supported factory types. * Supported factory types.
*/ */

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import java.time.Duration; import java.time.Duration;
import java.util.Objects; import java.util.Objects;
@ -22,12 +22,12 @@ import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.http.client.AbstractHttpClientProperties.Ssl;
import org.springframework.boot.autoconfigure.http.client.AbstractHttpRequestFactoryProperties.Factory;
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects;
import org.springframework.boot.http.client.HttpRedirects; import org.springframework.boot.http.client.HttpRedirects;
import org.springframework.boot.http.client.autoconfigure.AbstractHttpRequestFactoryProperties.Factory;
import org.springframework.boot.http.client.autoconfigure.AbstractHttpRequestFactoryProperties.Ssl;
import org.springframework.boot.ssl.SslBundle; import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundles; import org.springframework.boot.ssl.SslBundles;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
@ -24,7 +24,7 @@ import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
* *
* @param <B> the builder type * @param <B> the builder type
* @author Phillip Webb * @author Phillip Webb
* @since 3.5.0 * @since 4.0.0
*/ */
public interface ClientHttpRequestFactoryBuilderCustomizer<B extends ClientHttpRequestFactoryBuilder<?>> { public interface ClientHttpRequestFactoryBuilderCustomizer<B extends ClientHttpRequestFactoryBuilder<?>> {

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import java.util.List; import java.util.List;
@ -39,7 +39,7 @@ import org.springframework.http.client.ClientHttpRequestFactory;
* {@link ClientHttpRequestFactoryBuilder} and {@link ClientHttpRequestFactorySettings}. * {@link ClientHttpRequestFactoryBuilder} and {@link ClientHttpRequestFactorySettings}.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 3.4.0 * @since 4.0.0
*/ */
@SuppressWarnings("removal") @SuppressWarnings("removal")
@AutoConfiguration(after = SslAutoConfiguration.class) @AutoConfiguration(after = SslAutoConfiguration.class)

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import java.time.Duration; import java.time.Duration;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.http.client.reactive.ClientHttpConnectorSettings; import org.springframework.boot.http.client.reactive.ClientHttpConnectorSettings;
@ -24,7 +24,7 @@ import org.springframework.boot.http.client.reactive.ClientHttpConnectorSettings
* apply to Spring's blocking HTTP clients. * apply to Spring's blocking HTTP clients.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 3.5.0 * @since 4.0.0
* @see ClientHttpConnectorSettings * @see ClientHttpConnectorSettings
*/ */
@ConfigurationProperties("spring.http.client.settings") @ConfigurationProperties("spring.http.client.settings")

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.autoconfigure;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; import org.springframework.boot.autoconfigure.condition.NoneNestedConditions;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,4 +17,4 @@
/** /**
* Auto-configuration for client-side HTTP. * Auto-configuration for client-side HTTP.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.function.Consumer; import java.util.function.Consumer;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -30,7 +30,7 @@ import org.springframework.web.client.RestClient;
* HttpMessageConverters}. * HttpMessageConverters}.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 3.2.0 * @since 4.0.0
*/ */
public class HttpMessageConvertersRestClientCustomizer implements RestClientCustomizer { public class HttpMessageConvertersRestClientCustomizer implements RestClientCustomizer {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.rest.autoconfigure;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.NoneNestedConditions; import org.springframework.boot.autoconfigure.condition.NoneNestedConditions;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import org.springframework.boot.autoconfigure.condition.AnyNestedCondition; import org.springframework.boot.autoconfigure.condition.AnyNestedCondition;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
@ -23,12 +23,12 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration;
import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration; import org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConverters; import org.springframework.boot.http.autoconfigure.HttpMessageConverters;
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
import org.springframework.boot.http.client.autoconfigure.HttpClientAutoConfiguration;
import org.springframework.boot.ssl.SslBundles; import org.springframework.boot.ssl.SslBundles;
import org.springframework.boot.web.client.RestClientCustomizer; import org.springframework.boot.web.client.RestClientCustomizer;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -48,7 +48,7 @@ import org.springframework.web.client.RestClient.Builder;
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Moritz Halbritter * @author Moritz Halbritter
* @since 3.2.0 * @since 4.0.0
*/ */
@AutoConfiguration( @AutoConfiguration(
after = { HttpClientAutoConfiguration.class, TaskExecutionAutoConfiguration.class, SslAutoConfiguration.class }) after = { HttpClientAutoConfiguration.class, TaskExecutionAutoConfiguration.class, SslAutoConfiguration.class })

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -29,7 +29,7 @@ import org.springframework.web.client.RestClient.Builder;
* Configure {@link Builder RestClient.Builder} with sensible defaults. * Configure {@link Builder RestClient.Builder} with sensible defaults.
* *
* @author Moritz Halbritter * @author Moritz Halbritter
* @since 3.2.0 * @since 4.0.0
*/ */
public class RestClientBuilderConfigurer { public class RestClientBuilderConfigurer {

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -44,7 +44,7 @@ import org.springframework.web.client.RestClient;
* consider using a {@link ClientHttpRequestFactoryBuilder}. * consider using a {@link ClientHttpRequestFactoryBuilder}.
* *
* @author Phillip Webb * @author Phillip Webb
* @since 3.2.0 * @since 4.0.0
*/ */
public interface RestClientSsl { public interface RestClientSsl {

View File

@ -14,17 +14,17 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConverters; import org.springframework.boot.http.autoconfigure.HttpMessageConverters;
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
import org.springframework.boot.http.client.autoconfigure.HttpClientAutoConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.client.RestTemplateCustomizer; import org.springframework.boot.web.client.RestTemplateCustomizer;
import org.springframework.boot.web.client.RestTemplateRequestCustomizer; import org.springframework.boot.web.client.RestTemplateRequestCustomizer;
@ -39,7 +39,7 @@ import org.springframework.web.client.RestTemplate;
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 4.0.0
*/ */
@AutoConfiguration(after = HttpClientAutoConfiguration.class) @AutoConfiguration(after = HttpClientAutoConfiguration.class)
@ConditionalOnClass({ RestTemplate.class, HttpMessageConverters.class }) @ConditionalOnClass({ RestTemplate.class, HttpMessageConverters.class })

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -32,7 +32,7 @@ import org.springframework.util.ObjectUtils;
* Configure {@link RestTemplateBuilder} with sensible defaults. * Configure {@link RestTemplateBuilder} with sensible defaults.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 2.4.0 * @since 4.0.0
*/ */
public final class RestTemplateBuilderConfigurer { public final class RestTemplateBuilderConfigurer {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,4 +17,4 @@
/** /**
* Auto-configuration for web clients. * Auto-configuration for web clients.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;

View File

@ -0,0 +1,3 @@
org.springframework.boot.http.client.autoconfigure.HttpClientAutoConfiguration
org.springframework.boot.http.client.rest.autoconfigure.RestClientAutoConfiguration
org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -14,17 +14,17 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.http.client; package org.springframework.boot.http.client.autoconfigure;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.http.client.AbstractHttpRequestFactoryProperties.Factory;
import org.springframework.boot.http.client.HttpComponentsClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.HttpComponentsClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.JdkClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.JdkClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.JettyClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.JettyClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.ReactorClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ReactorClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.SimpleClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.SimpleClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.autoconfigure.AbstractHttpRequestFactoryProperties.Factory;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.time.Duration; import java.time.Duration;
import java.util.function.Consumer; import java.util.function.Consumer;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.time.Duration; import java.time.Duration;
import java.util.List; import java.util.List;
@ -24,13 +24,13 @@ import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.api.condition.JRE;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration;
import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration; import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConverters; import org.springframework.boot.http.autoconfigure.HttpMessageConverters;
import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder; import org.springframework.boot.http.client.ClientHttpRequestFactoryBuilder;
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects; import org.springframework.boot.http.client.ClientHttpRequestFactorySettings.Redirects;
import org.springframework.boot.http.client.autoconfigure.HttpClientAutoConfiguration;
import org.springframework.boot.ssl.SslBundle; import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundles; import org.springframework.boot.ssl.SslBundles;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.List; import java.util.List;

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.boot.autoconfigure.web.client; package org.springframework.boot.http.client.rest.autoconfigure;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionOverrideException; import org.springframework.beans.factory.support.BeanDefinitionOverrideException;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.http.client.HttpClientAutoConfiguration;
import org.springframework.boot.http.autoconfigure.HttpMessageConverters; import org.springframework.boot.http.autoconfigure.HttpMessageConverters;
import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration; import org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.http.client.autoconfigure.HttpClientAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.boot.test.context.runner.WebApplicationContextRunner; import org.springframework.boot.test.context.runner.WebApplicationContextRunner;

View File

@ -5,6 +5,7 @@ plugins {
description = "Starter for testing Spring Boot applications with libraries including JUnit Jupiter, Hamcrest and Mockito" description = "Starter for testing Spring Boot applications with libraries including JUnit Jupiter, Hamcrest and Mockito"
dependencies { dependencies {
api(project(":spring-boot-project:spring-boot-http-client"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api(project(":spring-boot-project:spring-boot-test")) api(project(":spring-boot-project:spring-boot-test"))
api(project(":spring-boot-project:spring-boot-test-autoconfigure")) api(project(":spring-boot-project:spring-boot-test-autoconfigure"))

View File

@ -53,6 +53,7 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-groovy-templates")) optional(project(":spring-boot-project:spring-boot-groovy-templates"))
optional(project(":spring-boot-project:spring-boot-hateoas")) optional(project(":spring-boot-project:spring-boot-hateoas"))
optional(project(":spring-boot-project:spring-boot-http")) optional(project(":spring-boot-project:spring-boot-http"))
optional(project(":spring-boot-project:spring-boot-http-client"))
optional(project(":spring-boot-project:spring-boot-http-codec")) optional(project(":spring-boot-project:spring-boot-http-codec"))
optional(project(":spring-boot-project:spring-boot-jackson")) optional(project(":spring-boot-project:spring-boot-jackson"))
optional(project(":spring-boot-project:spring-boot-jdbc")) optional(project(":spring-boot-project:spring-boot-jdbc"))

View File

@ -18,7 +18,6 @@ package org.springframework.boot.test.autoconfigure.web.client;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
@ -31,7 +30,7 @@ import org.springframework.web.client.RestTemplate;
* @since 1.4.0 * @since 1.4.0
* @see AutoConfigureMockRestServiceServer * @see AutoConfigureMockRestServiceServer
*/ */
@AutoConfiguration(after = RestTemplateAutoConfiguration.class) @AutoConfiguration(afterName = "org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration")
@ConditionalOnBooleanProperty("spring.test.webclient.register-rest-template") @ConditionalOnBooleanProperty("spring.test.webclient.register-rest-template")
public class WebClientRestTemplateAutoConfiguration { public class WebClientRestTemplateAutoConfiguration {

View File

@ -1,7 +1,7 @@
# AutoConfigureWebClient auto-configuration imports # AutoConfigureWebClient auto-configuration imports
optional:org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration
optional:org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration optional:org.springframework.boot.http.autoconfigure.HttpMessageConvertersAutoConfiguration
org.springframework.boot.test.autoconfigure.web.client.WebClientRestTemplateAutoConfiguration optional:org.springframework.boot.http.client.rest.autoconfigure.RestClientAutoConfiguration
org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration optional:org.springframework.boot.http.client.rest.autoconfigure.RestTemplateAutoConfiguration
org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration optional:org.springframework.boot.http.codec.autoconfigure.CodecsAutoConfiguration
org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration
org.springframework.boot.test.autoconfigure.web.client.WebClientRestTemplateAutoConfiguration

View File

@ -11,6 +11,7 @@ configurations {
dependencies { dependencies {
app project(path: ":spring-boot-project:spring-boot-dependencies", configuration: "mavenRepository") app project(path: ":spring-boot-project:spring-boot-dependencies", configuration: "mavenRepository")
app project(path: ":spring-boot-project:spring-boot-http-client", configuration: "mavenRepository")
app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter", configuration: "mavenRepository") app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter", configuration: "mavenRepository")
app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator", configuration: "mavenRepository") app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator", configuration: "mavenRepository")
app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-tomcat", configuration: "mavenRepository") app project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-tomcat", configuration: "mavenRepository")

View File

@ -17,5 +17,6 @@ repositories {
dependencies { dependencies {
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)) implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
implementation("org.springframework.boot:spring-boot-http-client")
implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-web")
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2024 the original author or authors. * Copyright 2012-2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,8 +21,8 @@ import java.util.Arrays;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.WebApplicationType; import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.client.RestClientSsl;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.http.client.rest.autoconfigure.RestClientSsl;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert; import org.springframework.util.Assert;