Update springboot templates to Spring Boot 3.0.2 (#1509)

- add needed buildEnv properties
- add class to register runtime hints for MessageUtils.MessageStructureWithCaseInsensitiveHeaderKeys
- update README files
- update unit tests to use Java 17

Signed-off-by: Thomas Risberg <trisberg@pivotal.io>

Signed-off-by: Thomas Risberg <trisberg@pivotal.io>
This commit is contained in:
Thomas Risberg 2023-01-24 10:16:38 -05:00 committed by GitHub
parent c3c5d32d7c
commit d090d5dd5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 6529 additions and 6479 deletions

View File

@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
go: [1.18.x]
java: [11]
java: [17]
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
runs-on: ${{ matrix.os }}
steps:

View File

@ -6,7 +6,7 @@ This sample project contains a single function based on Spring Cloud Function: `
## Local execution
Make sure that `Java 11 SDK` is installed.
Make sure that `Java 17 SDK` is installed since Spring Boot 3.0 requires Java 17.
To start server locally run `./mvnw spring-boot:run`.
The command starts http server and automatically watches for changes of source code.
@ -35,7 +35,7 @@ func build -v # build image
```
**Note**: If you want to enable the native build, you need to edit the `func.yaml` file and
set the following BuilderEnv variable:
set the `BP_NATIVE_IMAGE` BuilderEnv variable to true:
```yaml
buildEnvs:
@ -43,6 +43,16 @@ buildEnvs:
value: "true"
```
**Note**: If you have issues with the [Spring AOT](https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#core.aot) processing in your build, you can turn this off by editing the `func.yaml` file and remove the `-Pnative` profile from the `BP_MAVEN_BUILD_ARGUMENTS` BuilderEnv variable:
```yaml
buildEnvs:
- name: BP_MAVEN_BUILD_ARGUMENTS
value: -Pnative -Dmaven.test.skip=true --no-transfer-progress package
```
> Removing the `-Pnative` profile means that you no longer will be able to build as a native image.
### Running
This command runs the func locally in a container

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.7</version>
<version>3.0.2</version>
<relativePath/>
</parent>
@ -17,13 +17,12 @@
<description>A Spring Cloud Function, using Cloud Events</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-native.version>0.12.2</spring-native.version>
<java.version>17</java.version>
<spring-cloud.version>2022.0.0</spring-cloud.version>
<compiler-plugin.version>3.10.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
@ -72,13 +71,4 @@
</plugin>
</plugins>
</build>
</project>

View File

@ -1,11 +1,26 @@
package echo;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.function.context.message.MessageUtils;
import org.springframework.context.annotation.ImportRuntimeHints;
@SpringBootApplication
@ImportRuntimeHints(SpringCloudEventsApplication.MessageHeaderHints.class)
public class SpringCloudEventsApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudEventsApplication.class, args);
}
static class MessageHeaderHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(MessageUtils.MessageStructureWithCaseInsensitiveHeaderKeys.class,
MemberCategory.INVOKE_PUBLIC_METHODS);
}
}
}

View File

@ -6,7 +6,7 @@ This sample project contains a single function based on Spring Cloud Function: `
## Local execution
Make sure that `Java 11 SDK` is installed.
Make sure that `Java 17 SDK` is installed since Spring Boot 3.0 requires Java 17.
To start server locally run `./mvnw spring-boot:run`.
The command starts http server and automatically watches for changes of source code.
@ -35,7 +35,7 @@ func build -v # build image
```
**Note**: If you want to enable the native build, you need to edit the `func.yaml` file and
set the following BuilderEnv variable:
set the `BP_NATIVE_IMAGE` BuilderEnv variable to true:
```yaml
buildEnvs:
@ -43,6 +43,16 @@ buildEnvs:
value: "true"
```
**Note**: If you have issues with the [Spring AOT](https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#core.aot) processing in your build, you can turn this off by editing the `func.yaml` file and remove the `-Pnative` profile from the `BP_MAVEN_BUILD_ARGUMENTS` BuilderEnv variable:
```yaml
buildEnvs:
- name: BP_MAVEN_BUILD_ARGUMENTS
value: -Pnative -Dmaven.test.skip=true --no-transfer-progress package
```
> Removing the `-Pnative` profile means that you no longer will be able to build as a native image.
### Running
This command runs the func locally in a container

View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.7</version>
<version>3.0.2</version>
<relativePath/>
</parent>
@ -17,13 +17,12 @@
<description>A Spring Cloud Function, Http Example</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-native.version>0.12.2</spring-native.version>
<java.version>17</java.version>
<spring-cloud.version>2022.0.0</spring-cloud.version>
<compiler-plugin.version>3.10.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
@ -72,5 +71,4 @@
</plugin>
</plugins>
</build>
</project>

View File

@ -1,6 +1,10 @@
buildEnvs:
- name: BP_NATIVE_IMAGE
value: "false"
- name: BP_JVM_VERSION
value: "17"
- name: BP_MAVEN_BUILD_ARGUMENTS
value: "-Pnative -Dmaven.test.skip=true --no-transfer-progress package"
healthEndpoints:
liveness: /actuator/health
readiness: /actuator/health

12927
zz_filesystem_generated.go generated

File diff suppressed because it is too large Load Diff