Skip to content

Commit ba655c6

Browse files
authored
Adapt to restructuring changes in Spring Boot 4.0 (#1519)
This commit updates imports and dependencies to adapt to Spring Boot 4.0's restructuring. Both SimpleDiscoveryClientAutoConfiguration and SimpleDiscoveryClientAutoConfiguration have been reworked as ServerProperties and WebServerInitializedEvent may not be on the classpath due them moving to spring-boot-web-server. This commit also updates code that was using APIs that were deprecated in Spring Boot 3.x and that have now been removed. Signed-off-by: Andy Wilkinson <[email protected]>
1 parent d64dcd8 commit ba655c6

File tree

56 files changed

+427
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+427
-307
lines changed

spring-cloud-commons/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@
112112
<artifactId>spring-boot-configuration-processor</artifactId>
113113
<optional>true</optional>
114114
</dependency>
115+
<dependency>
116+
<groupId>org.springframework.boot</groupId>
117+
<artifactId>spring-boot-restclient</artifactId>
118+
<optional>true</optional>
119+
</dependency>
115120
<dependency>
116121
<groupId>org.springframework.boot</groupId>
117122
<artifactId>spring-boot-starter-actuator</artifactId>
@@ -127,6 +132,11 @@
127132
<artifactId>spring-boot-starter-webflux</artifactId>
128133
<optional>true</optional>
129134
</dependency>
135+
<dependency>
136+
<groupId>org.springframework.boot</groupId>
137+
<artifactId>spring-boot-webclient</artifactId>
138+
<optional>true</optional>
139+
</dependency>
130140
<dependency>
131141
<groupId>org.springframework.security</groupId>
132142
<artifactId>spring-security-crypto</artifactId>

spring-cloud-commons/src/main/java/org/springframework/cloud/client/CommonsClientAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -23,12 +23,12 @@
2323
import org.springframework.beans.factory.annotation.Autowired;
2424
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
2525
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
26-
import org.springframework.boot.actuate.health.HealthIndicator;
2726
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2827
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2928
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3029
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3130
import org.springframework.boot.context.properties.EnableConfigurationProperties;
31+
import org.springframework.boot.health.contributor.HealthIndicator;
3232
import org.springframework.cloud.client.actuator.FeaturesEndpoint;
3333
import org.springframework.cloud.client.actuator.HasFeatures;
3434
import org.springframework.cloud.client.discovery.DiscoveryClient;

spring-cloud-commons/src/main/java/org/springframework/cloud/client/ReactiveCommonsClientAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -18,12 +18,12 @@
1818

1919
import java.util.Collection;
2020

21-
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
2221
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2322
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
2423
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2524
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2625
import org.springframework.boot.context.properties.EnableConfigurationProperties;
26+
import org.springframework.boot.health.contributor.ReactiveHealthIndicator;
2727
import org.springframework.cloud.client.actuator.HasFeatures;
2828
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
2929
import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicatorProperties;

spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/ManagementServerPortUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -19,7 +19,7 @@
1919
import org.springframework.beans.factory.BeanFactory;
2020
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2121
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
22-
import org.springframework.boot.autoconfigure.web.ServerProperties;
22+
import org.springframework.boot.web.server.autoconfigure.ServerProperties;
2323
import org.springframework.web.context.WebApplicationContext;
2424

2525
/**

spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryClientHealthIndicator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -23,8 +23,8 @@
2323
import org.apache.commons.logging.LogFactory;
2424

2525
import org.springframework.beans.factory.ObjectProvider;
26-
import org.springframework.boot.actuate.health.Health;
27-
import org.springframework.boot.actuate.health.Status;
26+
import org.springframework.boot.health.contributor.Health;
27+
import org.springframework.boot.health.contributor.Status;
2828
import org.springframework.cloud.client.discovery.DiscoveryClient;
2929
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
3030
import org.springframework.context.ApplicationListener;

spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthContributor.java

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -18,15 +18,14 @@
1818

1919
import java.util.Collection;
2020
import java.util.Collections;
21-
import java.util.Iterator;
2221
import java.util.Map;
2322
import java.util.function.Function;
2423
import java.util.stream.Collectors;
24+
import java.util.stream.Stream;
2525

26-
import org.springframework.boot.actuate.health.CompositeHealthContributor;
27-
import org.springframework.boot.actuate.health.HealthContributor;
28-
import org.springframework.boot.actuate.health.HealthIndicator;
29-
import org.springframework.boot.actuate.health.NamedContributor;
26+
import org.springframework.boot.health.contributor.CompositeHealthContributor;
27+
import org.springframework.boot.health.contributor.HealthContributor;
28+
import org.springframework.boot.health.contributor.HealthIndicator;
3029
import org.springframework.util.Assert;
3130

3231
/**
@@ -47,29 +46,15 @@ public DiscoveryCompositeHealthContributor(Collection<DiscoveryHealthIndicator>
4746
}
4847

4948
@Override
50-
public HealthContributor getContributor(String name) {
51-
return asHealthIndicator(this.indicators.get(name));
49+
public Stream<Entry> stream() {
50+
return indicators.entrySet()
51+
.stream()
52+
.map((entry) -> new Entry(entry.getKey(), asHealthIndicator(entry.getValue())));
5253
}
5354

5455
@Override
55-
public Iterator<NamedContributor<HealthContributor>> iterator() {
56-
return this.indicators.values().stream().map(this::asNamedContributor).iterator();
57-
}
58-
59-
private NamedContributor<HealthContributor> asNamedContributor(DiscoveryHealthIndicator indicator) {
60-
return new NamedContributor<>() {
61-
62-
@Override
63-
public String getName() {
64-
return indicator.getName();
65-
}
66-
67-
@Override
68-
public HealthIndicator getContributor() {
69-
return asHealthIndicator(indicator);
70-
}
71-
72-
};
56+
public HealthContributor getContributor(String name) {
57+
return asHealthIndicator(this.indicators.get(name));
7358
}
7459

7560
private HealthIndicator asHealthIndicator(DiscoveryHealthIndicator indicator) {

spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryHealthIndicator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.cloud.client.discovery.health;
1818

19-
import org.springframework.boot.actuate.health.Health;
19+
import org.springframework.boot.health.contributor.Health;
2020

2121
/**
2222
* A health indicator interface specific to a DiscoveryClient implementation.

spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/reactive/ReactiveDiscoveryClientHealthIndicator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -22,8 +22,8 @@
2222
import org.apache.commons.logging.LogFactory;
2323
import reactor.core.publisher.Mono;
2424

25-
import org.springframework.boot.actuate.health.Health;
26-
import org.springframework.boot.actuate.health.Status;
25+
import org.springframework.boot.health.contributor.Health;
26+
import org.springframework.boot.health.contributor.Status;
2727
import org.springframework.cloud.client.discovery.ReactiveDiscoveryClient;
2828
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
2929
import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicatorProperties;

spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/reactive/ReactiveDiscoveryCompositeHealthContributor.java

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -17,15 +17,14 @@
1717
package org.springframework.cloud.client.discovery.health.reactive;
1818

1919
import java.util.Collection;
20-
import java.util.Iterator;
2120
import java.util.Map;
2221
import java.util.function.Function;
2322
import java.util.stream.Collectors;
23+
import java.util.stream.Stream;
2424

25-
import org.springframework.boot.actuate.health.CompositeReactiveHealthContributor;
26-
import org.springframework.boot.actuate.health.NamedContributor;
27-
import org.springframework.boot.actuate.health.ReactiveHealthContributor;
28-
import org.springframework.boot.actuate.health.ReactiveHealthIndicator;
25+
import org.springframework.boot.health.contributor.CompositeReactiveHealthContributor;
26+
import org.springframework.boot.health.contributor.ReactiveHealthContributor;
27+
import org.springframework.boot.health.contributor.ReactiveHealthIndicator;
2928
import org.springframework.util.Assert;
3029

3130
/**
@@ -44,29 +43,15 @@ public ReactiveDiscoveryCompositeHealthContributor(Collection<ReactiveDiscoveryH
4443
}
4544

4645
@Override
47-
public ReactiveHealthContributor getContributor(String name) {
48-
return asHealthIndicator(indicators.get(name));
46+
public Stream<Entry> stream() {
47+
return indicators.entrySet()
48+
.stream()
49+
.map((entry) -> new Entry(entry.getKey(), asHealthIndicator(entry.getValue())));
4950
}
5051

5152
@Override
52-
public Iterator<NamedContributor<ReactiveHealthContributor>> iterator() {
53-
return indicators.values().stream().map(this::asNamedContributor).iterator();
54-
}
55-
56-
private NamedContributor<ReactiveHealthContributor> asNamedContributor(ReactiveDiscoveryHealthIndicator indicator) {
57-
return new NamedContributor<>() {
58-
59-
@Override
60-
public String getName() {
61-
return indicator.getName();
62-
}
63-
64-
@Override
65-
public ReactiveHealthContributor getContributor() {
66-
return asHealthIndicator(indicator);
67-
}
68-
69-
};
53+
public ReactiveHealthContributor getContributor(String name) {
54+
return asHealthIndicator(indicators.get(name));
7055
}
7156

7257
private ReactiveHealthIndicator asHealthIndicator(ReactiveDiscoveryHealthIndicator indicator) {

spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/reactive/ReactiveDiscoveryHealthIndicator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 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.
@@ -18,7 +18,7 @@
1818

1919
import reactor.core.publisher.Mono;
2020

21-
import org.springframework.boot.actuate.health.Health;
21+
import org.springframework.boot.health.contributor.Health;
2222

2323
/**
2424
* A health indicator interface specific to a reactive discovery client implementation.

0 commit comments

Comments
 (0)