Skip to content

Remove deprecated classes and methods #2908

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 87 additions & 4 deletions docs/modules/ROOT/pages/quickstart.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,97 @@

This quick start walks through using both the server and the client of Spring Cloud Config Server.

First, start the server, as follows:
First create a Spring Boot application with a dependency on `org.springframework.cloud:spring-cloud-config-server`.

.pom.xml
[source,xml]
----
...
<properties>
<java.version>21</java.version>
<spring-cloud.version>2025.1.0</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
----

.build.gradle
[source,json]
----
...
ext {
set('springCloudVersion', "2025.1.0")
}

dependencies {
implementation 'org.springframework.cloud:spring-cloud-config-server'
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
...
----
$ cd spring-cloud-config-server
$ ../mvnw spring-boot:run

In the main application class add the `@EnableConfigServer` annotation.

.ConfigServerApplication.java
[source,java]
----
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {

public static void main(String[] args) {
new SpringApplicationBuilder(ConfigServerApplication.class).run(args);
}

The server is a Spring Boot application, so you can run it from your IDE if you prefer to do so (the main class is `ConfigServerApplication`).
}
----

Finally in your `application.yaml` file (or `application.properties`) add the following properties.

.application.yaml
[source,yaml]
----
spring:
application:
name: configserver
cloud:
config:
server:
git:
uri: https://github.com/spring-cloud-samples/config-repo
repos:
- patterns: multi-repo-demo-*
uri: https://github.com/spring-cloud-samples/config-repo
server:
port: 8888
----

Next try out a client, as follows:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,4 @@ else if (response.getStatusCode() != HttpStatus.OK) {
return null;
}

@Deprecated
protected void addAuthorizationToken(ConfigClientProperties configClientProperties, HttpHeaders httpHeaders,
String username, String password) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ private BindHandler getBindHandler(ConfigDataLocationResolverContext context) {
return context.getBootstrapContext().getOrElse(BindHandler.class, null);
}

@Deprecated
protected RestTemplate createRestTemplate(ConfigClientProperties properties) {
return null;
}

protected Log getLog() {
return this.log;
}
Expand Down Expand Up @@ -250,11 +245,6 @@ public List<ConfigServerConfigDataResource> resolveProfileSpecific(

bootstrapContext.registerIfAbsent(RestTemplate.class, context -> {
ConfigClientRequestTemplateFactory factory = context.get(ConfigClientRequestTemplateFactory.class);
RestTemplate restTemplate = createRestTemplate(factory.getProperties());
if (restTemplate != null) {
// shouldn't normally happen
return restTemplate;
}
return factory.create();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.springframework.boot.context.properties.bind.BindHandler;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.retry.annotation.Retryable;

/**
Expand All @@ -42,11 +41,6 @@ public class ConfigServerInstanceProvider {

private Binder binder;

@Deprecated
public ConfigServerInstanceProvider(DiscoveryClient client) {
this.function = client::getInstances;
}

public ConfigServerInstanceProvider(Function function) {
this.function = function;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,19 +337,6 @@ public void setRestTemplate(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}

/**
* Adds the provided headers to the request.
*/
@Deprecated
public static class GenericRequestHeaderInterceptor
extends ConfigClientRequestTemplateFactory.GenericRequestHeaderInterceptor {

public GenericRequestHeaderInterceptor(Map<String, String> headers) {
super(headers);
}

}

static class ConfigServiceOrigin implements Origin {

private final String remotePropertySource;
Expand Down
5 changes: 5 additions & 0 deletions spring-cloud-config-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.vault</groupId>
<artifactId>spring-vault-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
Expand Down
2 changes: 0 additions & 2 deletions spring-cloud-config-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>org.springframework.cloud.config.server.ConfigServerApplication
</start-class>
</properties>
<build>
<plugins>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ public class ConfigServerHealthIndicator extends AbstractHealthIndicator {

private final boolean acceptEmpty;

@Deprecated
public ConfigServerHealthIndicator(EnvironmentRepository environmentRepository) {
this.environmentRepository = environmentRepository;
this.acceptEmpty = true;
}

// autowired required or boot constructor binding produces an error
@Autowired
public ConfigServerHealthIndicator(EnvironmentRepository environmentRepository, ConfigServerProperties properties) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down Expand Up @@ -64,7 +63,6 @@
import org.springframework.cloud.config.server.environment.GoogleSecretManagerEnvironmentRepositoryFactory;
import org.springframework.cloud.config.server.environment.HttpClient4BuilderCustomizer;
import org.springframework.cloud.config.server.environment.HttpClientConfigurableHttpConnectionFactory;
import org.springframework.cloud.config.server.environment.HttpClientVaultRestTemplateFactory;
import org.springframework.cloud.config.server.environment.HttpRequestConfigTokenProvider;
import org.springframework.cloud.config.server.environment.JdbcEnvironmentProperties;
import org.springframework.cloud.config.server.environment.JdbcEnvironmentRepository;
Expand All @@ -86,8 +84,6 @@
import org.springframework.cloud.config.server.environment.SvnKitEnvironmentProperties;
import org.springframework.cloud.config.server.environment.SvnKitEnvironmentRepository;
import org.springframework.cloud.config.server.environment.VaultEnvironmentProperties;
import org.springframework.cloud.config.server.environment.VaultEnvironmentRepository;
import org.springframework.cloud.config.server.environment.VaultEnvironmentRepositoryFactory;
import org.springframework.cloud.config.server.environment.vault.SpringVaultClientAuthenticationProvider;
import org.springframework.cloud.config.server.environment.vault.SpringVaultClientConfiguration;
import org.springframework.cloud.config.server.environment.vault.SpringVaultEnvironmentRepository;
Expand Down Expand Up @@ -128,12 +124,11 @@
AwsSecretsManagerEnvironmentProperties.class, AwsParameterStoreEnvironmentProperties.class,
GoogleSecretManagerEnvironmentProperties.class, MongoDbEnvironmentProperties.class })
@Import({ CompositeRepositoryConfiguration.class, JdbcRepositoryConfiguration.class, VaultConfiguration.class,
VaultRepositoryConfiguration.class, SpringVaultRepositoryConfiguration.class, CredhubConfiguration.class,
CredhubRepositoryConfiguration.class, SvnRepositoryConfiguration.class, NativeRepositoryConfiguration.class,
GitRepositoryConfiguration.class, RedisRepositoryConfiguration.class, GoogleCloudSourceConfiguration.class,
AwsS3RepositoryConfiguration.class, AwsSecretsManagerRepositoryConfiguration.class,
AwsParameterStoreRepositoryConfiguration.class, GoogleSecretManagerRepositoryConfiguration.class,
MongoRepositoryConfiguration.class,
SpringVaultRepositoryConfiguration.class, CredhubConfiguration.class, CredhubRepositoryConfiguration.class,
SvnRepositoryConfiguration.class, NativeRepositoryConfiguration.class, GitRepositoryConfiguration.class,
RedisRepositoryConfiguration.class, GoogleCloudSourceConfiguration.class, AwsS3RepositoryConfiguration.class,
AwsSecretsManagerRepositoryConfiguration.class, AwsParameterStoreRepositoryConfiguration.class,
GoogleSecretManagerRepositoryConfiguration.class, MongoRepositoryConfiguration.class,
// DefaultRepositoryConfiguration must be last
DefaultRepositoryConfiguration.class })
public class EnvironmentRepositoryConfiguration {
Expand Down Expand Up @@ -277,21 +272,6 @@ public SvnEnvironmentRepositoryFactory svnEnvironmentRepositoryFactory(Configura

}

@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingClass("org.springframework.vault.core.VaultTemplate")
@SuppressWarnings("deprecation")
static class VaultFactoryConfig {

@Bean
public VaultEnvironmentRepositoryFactory vaultEnvironmentRepositoryFactory(
ObjectProvider<HttpServletRequest> request, EnvironmentWatch watch,
Optional<VaultEnvironmentRepositoryFactory.VaultRestTemplateFactory> vaultRestTemplateFactory,
ConfigTokenProvider tokenProvider) {
return new VaultEnvironmentRepositoryFactory(request, watch, vaultRestTemplateFactory, tokenProvider);
}

}

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(SecretManagerServiceClient.class)
static class GoogleSecretManagerFactoryConfig {
Expand All @@ -304,19 +284,6 @@ public GoogleSecretManagerEnvironmentRepositoryFactory googleSecretManagerEnviro

}

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(HttpClient.class)
@ConditionalOnMissingClass("org.springframework.vault.core.VaultTemplate")
@SuppressWarnings("deprecation")
static class VaultHttpClientConfig {

@Bean
public VaultEnvironmentRepositoryFactory.VaultRestTemplateFactory vaultRestTemplateFactory() {
return new HttpClientVaultRestTemplateFactory();
}

}

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(VaultTemplate.class)
@Import(SpringVaultClientConfiguration.class)
Expand Down Expand Up @@ -493,20 +460,6 @@ public SvnKitEnvironmentRepository svnKitEnvironmentRepository(SvnEnvironmentRep

}

@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingClass("org.springframework.vault.core.VaultTemplate")
@Profile("vault")
@SuppressWarnings("deprecation")
class VaultRepositoryConfiguration {

@Bean
public VaultEnvironmentRepository vaultEnvironmentRepository(VaultEnvironmentRepositoryFactory factory,
VaultEnvironmentProperties environmentProperties) throws Exception {
return factory.build(environmentProperties);
}

}

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(VaultTemplate.class)
@Profile("vault")
Expand Down

This file was deleted.

Loading
Loading