Skip to content
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

Update Spring Boot to 2.7.7 #1502

Merged
merged 2 commits into from
Jan 18, 2023
Merged
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
88 changes: 88 additions & 0 deletions docs/function-templates/springboot.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Spring Boot Function Developer's Guide

When creating a Spring Boot function using the `func` CLI, the project
directory looks like a typical Boot project.
To create a HTTP function that echos the input run the following command:

```
❯ func create -l springboot fn
```

This is the HTTP function template structure:

```
Project path: /home/developer/projects/fn
Function name: fn
Language Runtime: springboot
Template: http
❯ tree
fn
├── func.yaml
├── mvnw
├── mvnw.cmd
├── pom.xml
├── README.md
└── src
├── main
│   ├── java
│   │   └── functions
│   │   └── CloudFunctionApplication.java
│   └── resources
│   └── application.properties
└── test
└── java
└── functions
└── EchoCaseFunctionTest.java
```

This is a full-featured, self-contained Spring Boot application that uses [Spring Cloud Function](https://spring.io/projects/spring-cloud-function) and [Spring WebFlux](https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html) web framework to listen for HTTP requests on port 8080.

See the generated [README.md](../../templates/springboot/http/README.md) for
details on building, testing, and deploying the HTTP app.

You may have noticed the `func.yaml` file. This is a configuration
file used by `func` to deploy your project as a service in your
kubernetes cluster.

For an event-triggered function, pass the `-t cloudevents` option to
generate an app capable of responding to
[CloudEvents](https://cloudevents.io):

```
❯ func create -l springboot -t cloudevents fn
```

A CloudEvent function have a similar template structure to the above HTTP function:

```
Project path: /home/developer/projects/fn
Function name: fn
Language Runtime: springboot
Template: cloudevents
❯ tree
fn
├── func.yaml
├── mvnw
├── mvnw.cmd
├── pom.xml
├── README.md
└── src
├── main
│   ├── java
│   │   └── echo
│   │   ├── EchoFunction.java
│   │   └── SpringCloudEventsApplication.java
│   └── resources
│   └── application.properties
└── test
└── java
└── echo
└── SpringCloudEventsApplicationTests.java
```

The handlers of each app differ slightly. See its generated
[README.md](../../templates/springboot/cloudevents/README.md) for more details.

Have fun!
11 changes: 11 additions & 0 deletions templates/springboot/cloudevents/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ This command will build and deploy the function into cluster.
func deploy -v # also triggers build
```

### For ARM processor based systems

Building Spring Boot apps with Paketo Buildpacks on an ARM processor based system, like an Apple Macbook with an M1 or M2 chip, doesn't work well at the moment.
To work around this you can build the image on your local system using [Jib](https://github.com/GoogleContainerTools/jib).
Then, you would deploy the Jib generated image.

```
./mvnw compile com.google.cloud.tools:jib-maven-plugin:3.3.1:dockerBuild -Dimage=$FUNC_REGISTRY/echo
func deploy --build=false --image=$FUNC_REGISTRY/echo
```

## Function invocation

Spring Cloud Functions allows you to route CloudEvents to specific functions using the `Ce-Type` attribute.
Expand Down
10 changes: 5 additions & 5 deletions templates/springboot/cloudevents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<version>2.7.7</version>
<relativePath/>
</parent>

Expand All @@ -18,9 +18,9 @@

<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
<spring-native.version>0.12.1</spring-native.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-native.version>0.12.2</spring-native.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>
Expand Down Expand Up @@ -128,7 +128,7 @@
<id>native</id>
<properties>
<repackage.classifier>exec</repackage.classifier>
<native-buildtools.version>0.9.11</native-buildtools.version>
<native-buildtools.version>0.9.12</native-buildtools.version>
</properties>
<dependencies>
<dependency>
Expand Down
11 changes: 11 additions & 0 deletions templates/springboot/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ This command will build and deploy the function into cluster.
func deploy -v # also triggers build
```

### For ARM processor based systems

Building Spring Boot apps with Paketo Buildpacks on an ARM processor based system, like an Apple Macbook with an M1 or M2 chip, doesn't work well at the moment.
To work around this you can build the image on your local system using [Jib](https://github.com/GoogleContainerTools/jib).
Then, you would deploy the Jib generated image.

```
./mvnw compile com.google.cloud.tools:jib-maven-plugin:3.3.1:dockerBuild -Dimage=$FUNC_REGISTRY/echo
func deploy --build=false --image=$FUNC_REGISTRY/echo
```

## Function invocation

For the examples below, please be sure to set the `URL` variable to the route of your function.
Expand Down
10 changes: 5 additions & 5 deletions templates/springboot/http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
<version>2.7.7</version>
<relativePath/>
</parent>

Expand All @@ -18,9 +18,9 @@

<properties>
<java.version>11</java.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
<spring-native.version>0.12.1</spring-native.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-native.version>0.12.2</spring-native.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>
Expand Down Expand Up @@ -128,7 +128,7 @@
<id>native</id>
<properties>
<repackage.classifier>exec</repackage.classifier>
<native-buildtools.version>0.9.11</native-buildtools.version>
<native-buildtools.version>0.9.12</native-buildtools.version>
</properties>
<dependencies>
<dependency>
Expand Down
Loading