Skip to content

Commit eef651d

Browse files
committed
Upgrade to Spring Boot 4.0
Signed-off-by: Sébastien Deleuze <[email protected]>
1 parent bfd16af commit eef651d

File tree

16 files changed

+61
-30
lines changed

16 files changed

+61
-30
lines changed

README.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/
2727
[[scratch]]
2828
== Starting with Spring Initializr
2929

30-
You can use this https://start.spring.io/#!type=maven-project&&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=reactive-web-service&name=reactive-web-service&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.reactivewebservice&dependencies=webflux[pre-initialized project] and click Generate to download a ZIP file. This project is configured to fit the examples in this tutorial.
30+
You can use this https://start.spring.io/#!type=gradle-project&language=java&packaging=jar&jvmVersion=17&groupId=com.example&artifactId=reactive-web-service&packageName=com.example.reactivewebservice&dependencies=webflux,spring-webclient[pre-initialized project] and click Generate to download a ZIP file. This project is configured to fit the examples in this tutorial.
3131

3232
To manually initialize the project:
3333

3434
. Navigate to https://start.spring.io.
3535
This service pulls in all the dependencies you need for an application and does most of the setup for you.
36-
. Choose either Gradle or Maven and the language you want to use: Kotlin or Java.
37-
. Click *Dependencies* and select *Spring Reactive Web*.
36+
. Choose either Gradle or Maven and the language you want to use.
37+
. Type "reactive-web-service" in the "Artifact" form field.
38+
. Click *Dependencies* and select *Spring Reactive Web* and *Reactive HTTP Client*.
3839
. Click *Generate*.
3940
. Download the resulting ZIP file, which is an archive of a web application that is configured with your choices.
4041

complete-kotlin/build.gradle.kts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
plugins {
2-
kotlin("jvm") version "1.9.25"
3-
kotlin("plugin.spring") version "1.9.25"
4-
id("org.springframework.boot") version "3.5.5"
2+
id("org.springframework.boot") version "4.0.0"
53
id("io.spring.dependency-management") version "1.1.7"
4+
kotlin("jvm") version "2.2.21"
5+
kotlin("plugin.spring") version "2.2.21"
66
}
77

88
group = "com.example"
99
version = "0.0.1-SNAPSHOT"
10-
java.sourceCompatibility = JavaVersion.VERSION_17
10+
11+
java {
12+
toolchain {
13+
languageVersion = JavaLanguageVersion.of(17)
14+
}
15+
}
1116

1217
repositories {
1318
mavenCentral()
1419
}
1520

1621
dependencies {
1722
implementation("org.springframework.boot:spring-boot-starter-webflux")
23+
implementation("org.springframework.boot:spring-boot-starter-webclient")
1824
implementation("org.jetbrains.kotlin:kotlin-reflect")
1925
testImplementation("org.springframework.boot:spring-boot-starter-test")
26+
testImplementation("org.springframework.boot:spring-boot-webtestclient")
2027
testImplementation("io.projectreactor:reactor-test")
2128
}
2229

2330
kotlin {
24-
jvmToolchain(17)
2531
compilerOptions {
26-
freeCompilerArgs.addAll("-Xjsr305=strict")
32+
freeCompilerArgs.addAll("-Xjsr305=strict", "-Xannotation-default-target=param-property")
2733
}
2834
}
2935

complete-kotlin/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = "reactive-web-service"
1+
rootProject.name = "reactive-web-service-complete"

complete-kotlin/src/test/kotlin/com/example/reactivewebservice/GreetingRouterTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ package com.example.reactivewebservice
33
import org.junit.jupiter.api.Test
44
import org.springframework.beans.factory.annotation.Autowired
55
import org.springframework.boot.test.context.SpringBootTest
6+
import org.springframework.boot.webtestclient.autoconfigure.AutoConfigureWebTestClient
67
import org.springframework.http.MediaType
78
import org.springframework.test.web.reactive.server.WebTestClient
89
import org.springframework.test.web.reactive.server.expectBody
910

1011
// We create a @SpringBootTest, starting an actual server on a RANDOM_PORT
1112
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
13+
@AutoConfigureWebTestClient
1214
class GreetingRouterTest(@Autowired private val webTestClient: WebTestClient) {
1315

1416
// Spring Boot will create a WebTestClient for you,

complete/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
plugins {
2-
id 'org.springframework.boot' version '3.5.5'
2+
id 'org.springframework.boot' version '4.0.0'
33
id 'io.spring.dependency-management' version '1.1.7'
44
id 'java'
55
}
66

77
group = 'com.example'
88
version = '0.0.1-SNAPSHOT'
9-
sourceCompatibility = '17'
9+
10+
java {
11+
toolchain {
12+
languageVersion = JavaLanguageVersion.of(17)
13+
}
14+
}
1015

1116
repositories {
1217
mavenCentral()
1318
}
1419

1520
dependencies {
1621
implementation 'org.springframework.boot:spring-boot-starter-webflux'
22+
implementation 'org.springframework.boot:spring-boot-starter-webclient'
1723
testImplementation 'org.springframework.boot:spring-boot-starter-test'
24+
testImplementation 'org.springframework.boot:spring-boot-webtestclient'
1825
testImplementation 'io.projectreactor:reactor-test'
1926
}
2027

complete/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

complete/pom.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.5.5</version>
8+
<version>4.0.0</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.example</groupId>
1212
<artifactId>reactive-rest-service-complete</artifactId>
1313
<version>0.0.1-SNAPSHOT</version>
14-
<name>reactive-rest-service-complete</name>
15-
<description>Demo project for Spring Boot</description>
14+
1615
<properties>
1716
<java.version>17</java.version>
1817
</properties>
@@ -21,12 +20,21 @@
2120
<groupId>org.springframework.boot</groupId>
2221
<artifactId>spring-boot-starter-webflux</artifactId>
2322
</dependency>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-webclient</artifactId>
26+
</dependency>
2427

2528
<dependency>
2629
<groupId>org.springframework.boot</groupId>
2730
<artifactId>spring-boot-starter-test</artifactId>
2831
<scope>test</scope>
2932
</dependency>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-webtestclient</artifactId>
36+
<scope>test</scope>
37+
</dependency>
3038
<dependency>
3139
<groupId>io.projectreactor</groupId>
3240
<artifactId>reactor-test</artifactId>

complete/settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'reactive-rest-service-complete'

complete/src/test/java/com/example/reactivewebservice/GreetingRouterTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import org.junit.jupiter.api.Test;
44
import org.springframework.beans.factory.annotation.Autowired;
55
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.boot.webtestclient.autoconfigure.AutoConfigureWebTestClient;
67
import org.springframework.http.MediaType;
78
import org.springframework.test.web.reactive.server.WebTestClient;
89

910
import static org.assertj.core.api.Assertions.assertThat;
1011

1112
// We create a `@SpringBootTest`, starting an actual server on a `RANDOM_PORT`
1213
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
14+
@AutoConfigureWebTestClient
1315
public class GreetingRouterTest {
1416

1517
// Spring Boot will create a `WebTestClient` for you,

0 commit comments

Comments
 (0)