Skip to content

Commit 48c255d

Browse files
committed
Adapt to restructuring changes in Spring Boot 4.0
This commit updates imports and dependencies to adapt to Spring Boot 4.0's restructuring. FunctionEndpointInitializer has been reworked to move references to classes that may not be on the classpath into a nested class. This addresses a failure when SpringFactoriesLoader's reflectively introspects the class to find its constructor. This commit also stops using some APIs that have been deprecated since Spring Boot 3.4. Signed-off-by: Andy Wilkinson <[email protected]>
1 parent 7968e4b commit 48c255d

File tree

46 files changed

+170
-153
lines changed

Some content is hidden

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

46 files changed

+170
-153
lines changed

spring-cloud-function-adapters/spring-cloud-function-adapter-gcp/src/test/java/org/springframework/cloud/function/adapter/gcp/integration/FunctionInvokerIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2020 the original author or authors.
2+
* Copyright 2020-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,7 +23,7 @@
2323

2424
import org.junit.jupiter.api.Test;
2525

26-
import org.springframework.boot.test.web.client.TestRestTemplate;
26+
import org.springframework.boot.web.server.test.client.TestRestTemplate;
2727
import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration;
2828
import org.springframework.context.annotation.Bean;
2929
import org.springframework.context.annotation.Configuration;

spring-cloud-function-adapters/spring-cloud-function-adapter-gcp/src/test/java/org/springframework/cloud/function/adapter/gcp/integration/LocalServerTestSupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2022 the original author or authors.
2+
* Copyright 2020-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.
@@ -35,7 +35,7 @@
3535
import com.google.cloud.functions.invoker.runner.Invoker;
3636
import com.google.gson.Gson;
3737

38-
import org.springframework.boot.test.web.client.TestRestTemplate;
38+
import org.springframework.boot.web.server.test.client.TestRestTemplate;
3939
import org.springframework.cloud.function.adapter.gcp.FunctionInvoker;
4040
import org.springframework.http.HttpEntity;
4141
import org.springframework.http.HttpHeaders;

spring-cloud-function-adapters/spring-cloud-function-serverless-web/pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</properties>
1919
<dependencies>
2020
<dependency>
21-
<groupId>org.springframework</groupId>
22-
<artifactId>spring-webmvc</artifactId>
21+
<groupId>org.springframework.boot</groupId>
22+
<artifactId>spring-boot-webmvc</artifactId>
2323
</dependency>
2424

2525
<!-- -->
@@ -60,5 +60,9 @@
6060
</exclusion>
6161
</exclusions>
6262
</dependency>
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-web-server</artifactId>
66+
</dependency>
6367
</dependencies>
6468
</project>

spring-cloud-function-adapters/spring-cloud-function-serverless-web/src/main/java/org/springframework/cloud/function/serverless/web/ServerlessAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024-2024 the original author or authors.
2+
* Copyright 2024-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,10 +24,10 @@
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2525
import org.springframework.boot.web.server.WebServer;
2626
import org.springframework.boot.web.server.WebServerException;
27+
import org.springframework.boot.web.server.servlet.ServletWebServerFactory;
28+
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
2729
import org.springframework.boot.web.servlet.ServletContextInitializer;
2830
import org.springframework.boot.web.servlet.ServletContextInitializerBeans;
29-
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
30-
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
3131
import org.springframework.cloud.function.serverless.web.ServerlessMVC.ProxyServletConfig;
3232
import org.springframework.context.ApplicationContext;
3333
import org.springframework.context.ApplicationContextAware;

spring-cloud-function-adapters/spring-cloud-function-serverless-web/src/main/java/org/springframework/cloud/function/serverless/web/ServerlessMVC.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2023 the original author or authors.
2+
* Copyright 2023-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.
@@ -46,8 +46,8 @@
4646
import org.apache.commons.logging.LogFactory;
4747

4848
import org.springframework.boot.SpringApplication;
49-
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
50-
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;
49+
import org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext;
50+
import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration;
5151
import org.springframework.http.HttpStatus;
5252
import org.springframework.lang.Nullable;
5353
import org.springframework.util.Assert;

spring-cloud-function-adapters/spring-cloud-function-serverless-web/src/main/java/org/springframework/cloud/function/serverless/web/ServerlessWebApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2023 the original author or authors.
2+
* Copyright 2023-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.
@@ -194,7 +194,7 @@ private void prepareContext(DefaultBootstrapContext bootstrapContext, Configurab
194194
listeners.contextPrepared(context);
195195
bootstrapContext.close(context);
196196
if (this.logStartupInfo) {
197-
logStartupInfo(context.getParent() == null);
197+
logStartupInfo(context);
198198
logStartupProfileInfo(context);
199199
}
200200
// Add boot specific singleton beans

spring-cloud-function-context/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
<groupId>com.fasterxml.jackson.core</groupId>
8181
<artifactId>jackson-databind</artifactId>
8282
</dependency>
83+
<dependency>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-jackson</artifactId>
86+
<scope>test</scope>
87+
</dependency>
8388

8489
<!-- KOTLIN -->
8590
<dependency>
@@ -142,6 +147,12 @@
142147
<artifactId>micrometer-tracing-bridge-otel</artifactId>
143148
<scope>test</scope>
144149
</dependency>
150+
<dependency>
151+
<groupId>org.springframework.boot</groupId>
152+
<artifactId>spring-boot-opentelemetry</artifactId>
153+
<scope>test</scope>
154+
</dependency>
155+
145156
</dependencies>
146157

147158
<build>

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/context/FunctionTypeProcessor.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 the original author or authors.
2+
* Copyright 2019-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,9 +31,6 @@
3131
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor;
3232
import org.springframework.beans.factory.aot.BeanFactoryInitializationCode;
3333
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
34-
import org.springframework.boot.http.client.ClientHttpRequestFactorySettings;
35-
import org.springframework.boot.web.server.Ssl;
36-
import org.springframework.boot.web.server.Ssl.ServerNameSslBundle;
3734
import org.springframework.cloud.function.context.catalog.FunctionTypeUtils;
3835
import org.springframework.cloud.function.context.config.FunctionContextUtils;
3936
import org.springframework.cloud.function.context.message.MessageUtils;
@@ -108,15 +105,6 @@ public void applyTo(GenerationContext generationContext, BeanFactoryInitializati
108105
// known static types
109106
runtimeHints.reflection().registerType(MessageUtils.MessageStructureWithCaseInsensitiveHeaderKeys.class,
110107
MemberCategory.INVOKE_PUBLIC_METHODS);
111-
112-
113-
// temporary due to bug in boot
114-
runtimeHints.reflection().registerType(ClientHttpRequestFactorySettings.class,
115-
MemberCategory.INVOKE_PUBLIC_METHODS);
116-
runtimeHints.reflection().registerType(Ssl.class,
117-
MemberCategory.INVOKE_PUBLIC_METHODS);
118-
runtimeHints.reflection().registerType(ServerNameSslBundle.class,
119-
MemberCategory.INVOKE_PUBLIC_METHODS);
120108
}
121109

122110
}

spring-cloud-function-context/src/main/java/org/springframework/cloud/function/observability/ObservationAutoConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2022 the original author or authors.
2+
* Copyright 2022-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.
@@ -29,7 +29,7 @@
2929
* @author Oleg Zhurakousky
3030
*/
3131
@Configuration(proxyBeanMethods = false)
32-
@ConditionalOnBean(org.springframework.boot.actuate.autoconfigure.observation.ObservationAutoConfiguration.class)
32+
@ConditionalOnBean(org.springframework.boot.observation.autoconfigure.ObservationAutoConfiguration.class)
3333
public class ObservationAutoConfiguration {
3434

3535
@Bean

spring-cloud-function-context/src/test/java/org/springframework/cloud/function/context/HybridFunctionalRegistrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2019 the original author or authors.
2+
* Copyright 2019-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
2424

2525
import org.springframework.boot.SpringBootConfiguration;
2626
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
27-
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
27+
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
2828
import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration;
2929
import org.springframework.context.ConfigurableApplicationContext;
3030
import org.springframework.messaging.Message;

0 commit comments

Comments
 (0)