-
Notifications
You must be signed in to change notification settings - Fork 571
Add Spring Boot 4.0 support with working samples #1585
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
tobixlea
wants to merge
17
commits into
aws:main
Choose a base branch
from
tobixlea:sjc-spring-boot-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b81f00b
Add Spring Boot 4.0 support with working samples
tobixlea 88f7283
add java25 runtime support to springboot4
tobixlea a39062c
remove duplicate code
tobixlea e424240
Add jackson 3.x support for springboot 4
tobixlea df4a108
fix compilation errors in jersey
tobixlea ae84261
fix jackson exception import issues
tobixlea 377dd70
add spring 7 support to jersey
tobixlea b694a46
fix junit and jackson dependency issues
tobixlea 6b1315b
use correct project version for spring 7
tobixlea 63673ae
springboot3 as standalone to keep jackson 2
tobixlea 0cf2ccb
exclude jackson 3 from springboot3 module
tobixlea 4210016
revert to 2.1.5 snapshot
tobixlea 2692177
use 2.1.5 version, not snapshot
tobixlea f4eb49e
use relative path instead of parent path for spotbugs filter
tobixlea 40f1e06
non snapshot version for sb3
tobixlea 54d3dc6
put exclude filter directly in springboot3 module
tobixlea 186a091
add Springboot4 to CI workflow
tobixlea File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <parent> | ||
| <artifactId>aws-serverless-java-container</artifactId> | ||
| <groupId>com.amazonaws.serverless</groupId> | ||
| <version>2.1.5-SNAPSHOT</version> | ||
| </parent> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <groupId>com.amazonaws.serverless</groupId> | ||
| <artifactId>aws-serverless-java-container-springboot4</artifactId> | ||
| <name>AWS Serverless Java container support - SpringBoot 4 implementation</name> | ||
| <description>Allows Java applications written for SpringBoot 4 to run in AWS Lambda</description> | ||
| <url>https://aws.amazon.com/lambda</url> | ||
| <version>2.1.5-SNAPSHOT</version> | ||
|
|
||
| <properties> | ||
| <spring.version>7.0.0</spring.version> | ||
| <springboot.version>4.0.0</springboot.version> | ||
| <springsecurity.version>7.0.0</springsecurity.version> | ||
| <springcloud.function.version>5.0.0</springcloud.function.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.springframework.cloud</groupId> | ||
| <artifactId>spring-cloud-function-serverless-web</artifactId> | ||
| <version>${springcloud.function.version}</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.amazonaws.serverless</groupId> | ||
| <artifactId>aws-serverless-java-container-core</artifactId> | ||
| <version>2.1.5-SNAPSHOT</version> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| <!-- Use Jackson 3.x for Spring Boot 4 compatibility --> | ||
| <dependency> | ||
| <groupId>tools.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>3.0.2</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>tools.jackson.core</groupId> | ||
| <artifactId>jackson-core</artifactId> | ||
| <version>3.0.2</version> | ||
| </dependency> | ||
| <!-- Also include Jackson 2.x for core library compatibility --> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <version>2.18.2</version> | ||
| </dependency> | ||
| <!-- Use Jackson 3.x for Spring Boot 4 compatibility --> | ||
| <dependency> | ||
| <groupId>tools.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
tobixlea marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <version>3.0.2</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.amazonaws.serverless</groupId> | ||
| <artifactId>aws-serverless-java-container-core</artifactId> | ||
| <version>2.1.5-SNAPSHOT</version> | ||
| <classifier>tests</classifier> | ||
| <type>test-jar</type> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework</groupId> | ||
| <artifactId>spring-webflux</artifactId> | ||
| <version>${spring.version}</version> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot</artifactId> | ||
| <version>${springboot.version}</version> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-autoconfigure</artifactId> | ||
| <version>${springboot.version}</version> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework</groupId> | ||
| <artifactId>spring-core</artifactId> | ||
| <version>${spring.version}</version> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework</groupId> | ||
| <artifactId>spring-context</artifactId> | ||
| <version>${spring.version}</version> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework</groupId> | ||
| <artifactId>spring-webmvc</artifactId> | ||
| <version>${spring.version}</version> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <source>25</source> | ||
| <target>25</target> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </project> | ||
97 changes: 97 additions & 0 deletions
97
...boot4/src/main/java/com/amazonaws/serverless/proxy/spring/AwsSpringAotTypesProcessor.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * Copyright 2024-2024 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 com.amazonaws.serverless.proxy.spring; | ||
|
|
||
| import com.amazonaws.serverless.proxy.model.*; | ||
| import org.springframework.aot.generate.GenerationContext; | ||
| import org.springframework.aot.hint.MemberCategory; | ||
| import org.springframework.aot.hint.RuntimeHints; | ||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; | ||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; | ||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; | ||
| import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | ||
|
|
||
| import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletResponse; | ||
| import com.fasterxml.jackson.core.JsonToken; | ||
|
|
||
| /** | ||
| * AOT Initialization processor required to register reflective hints for GraalVM. | ||
| * This is necessary to ensure proper JSON serialization/deserialization. | ||
| * It is registered with META-INF/spring/aot.factories | ||
| * | ||
| * @author Oleg Zhurakousky | ||
| */ | ||
| public class AwsSpringAotTypesProcessor implements BeanFactoryInitializationAotProcessor { | ||
|
|
||
| @Override | ||
| public BeanFactoryInitializationAotContribution processAheadOfTime(ConfigurableListableBeanFactory beanFactory) { | ||
| return new ReflectiveProcessorBeanFactoryInitializationAotContribution(); | ||
| } | ||
|
|
||
| private static final class ReflectiveProcessorBeanFactoryInitializationAotContribution implements BeanFactoryInitializationAotContribution { | ||
| @Override | ||
| public void applyTo(GenerationContext generationContext, BeanFactoryInitializationCode beanFactoryInitializationCode) { | ||
| RuntimeHints runtimeHints = generationContext.getRuntimeHints(); | ||
| // known static types | ||
|
|
||
| runtimeHints.reflection().registerType(AwsProxyRequest.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(AwsProxyResponse.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(SingleValueHeaders.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(JsonToken.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(MultiValuedTreeMap.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(Headers.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(AwsProxyRequestContext.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(ApiGatewayRequestIdentity.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES); | ||
| runtimeHints.reflection().registerType(AwsHttpServletResponse.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2ProxyRequest.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2HttpContext.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2ProxyRequestContext.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2AuthorizerMap.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2AuthorizerMap.HttpApiV2AuthorizerDeserializer.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2AuthorizerMap.HttpApiV2AuthorizerSerializer.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2IamAuthorizer.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| runtimeHints.reflection().registerType(HttpApiV2JwtAuthorizer.class, | ||
| MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS, | ||
| MemberCategory.DECLARED_FIELDS, MemberCategory.DECLARED_CLASSES, MemberCategory.INTROSPECT_DECLARED_METHODS); | ||
| } | ||
|
|
||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.