Skip to content

Commit 3996ecc

Browse files
committed
Upgrade to Spring Boot 4.0
1 parent bcfa61b commit 3996ecc

File tree

8 files changed

+51
-25
lines changed

8 files changed

+51
-25
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/
3535
[[scratch]]
3636
== Starting with Spring Initializr
3737

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

4040
To manually initialize the project:
4141

complete/build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
plugins {
2-
id 'org.springframework.boot' version '3.3.0'
32
id 'java'
3+
id 'org.springframework.boot' version '4.0.0'
4+
id 'io.spring.dependency-management' version '1.1.7'
45
}
56

67
apply plugin: 'io.spring.dependency-management'
78

89
group = 'com.example'
910
version = '0.0.1-SNAPSHOT'
10-
sourceCompatibility = '17'
11+
12+
java {
13+
toolchain {
14+
languageVersion = JavaLanguageVersion.of(17)
15+
}
16+
}
1117

1218
repositories {
1319
mavenCentral()
1420
}
1521

1622
dependencies {
1723
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
18-
implementation 'org.springframework.boot:spring-boot-starter-web'
24+
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
1925
developmentOnly 'org.springframework.boot:spring-boot-devtools'
20-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
26+
testImplementation 'org.springframework.boot:spring-boot-starter-thymeleaf-test'
27+
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
2128
}
2229

23-
test {
30+
tasks.named('test') {
2431
useJUnitPlatform()
2532
}

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.7-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: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.3.0</version>
8+
<version>4.0.0</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.example</groupId>
@@ -23,7 +23,7 @@
2323
</dependency>
2424
<dependency>
2525
<groupId>org.springframework.boot</groupId>
26-
<artifactId>spring-boot-starter-web</artifactId>
26+
<artifactId>spring-boot-starter-webmvc</artifactId>
2727
</dependency>
2828

2929
<dependency>
@@ -34,7 +34,12 @@
3434
</dependency>
3535
<dependency>
3636
<groupId>org.springframework.boot</groupId>
37-
<artifactId>spring-boot-starter-test</artifactId>
37+
<artifactId>spring-boot-starter-thymeleaf-test</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-webmvc-test</artifactId>
3843
<scope>test</scope>
3944
</dependency>
4045
</dependencies>

complete/src/test/java/com/example/servingwebcontent/ServingWebContentApplicationTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616

1717
package com.example.servingwebcontent;
1818

19-
import static org.hamcrest.Matchers.containsString;
20-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
21-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
22-
2319
import org.junit.jupiter.api.Test;
2420

2521
import org.springframework.beans.factory.annotation.Autowired;
26-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
22+
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
23+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
2724
import org.springframework.test.web.servlet.MockMvc;
2825

26+
import static org.hamcrest.Matchers.containsString;
27+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
28+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
29+
2930
@WebMvcTest(controllers = GreetingController.class)
31+
@AutoConfigureMockMvc
3032
public class ServingWebContentApplicationTest {
3133

3234
@Autowired

initial/build.gradle

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
plugins {
2-
id 'org.springframework.boot' version '3.3.0'
32
id 'java'
3+
id 'org.springframework.boot' version '4.0.0'
4+
id 'io.spring.dependency-management' version '1.1.7'
45
}
56

67
apply plugin: 'io.spring.dependency-management'
78

89
group = 'com.example'
910
version = '0.0.1-SNAPSHOT'
10-
sourceCompatibility = '17'
11+
12+
java {
13+
toolchain {
14+
languageVersion = JavaLanguageVersion.of(17)
15+
}
16+
}
1117

1218
repositories {
1319
mavenCentral()
1420
}
1521

1622
dependencies {
1723
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
18-
implementation 'org.springframework.boot:spring-boot-starter-web'
24+
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
1925
developmentOnly 'org.springframework.boot:spring-boot-devtools'
20-
testImplementation 'org.springframework.boot:spring-boot-starter-test'
26+
testImplementation 'org.springframework.boot:spring-boot-starter-thymeleaf-test'
27+
testImplementation 'org.springframework.boot:spring-boot-starter-webmvc-test'
2128
}
2229

23-
test {
30+
tasks.named('test') {
2431
useJUnitPlatform()
2532
}

initial/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.7-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

initial/pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.3.1</version>
8+
<version>4.0.0</version>
99
<relativePath/> <!-- lookup parent from repository -->
1010
</parent>
1111
<groupId>com.example</groupId>
@@ -23,7 +23,7 @@
2323
</dependency>
2424
<dependency>
2525
<groupId>org.springframework.boot</groupId>
26-
<artifactId>spring-boot-starter-web</artifactId>
26+
<artifactId>spring-boot-starter-webmvc</artifactId>
2727
</dependency>
2828

2929
<dependency>
@@ -34,7 +34,12 @@
3434
</dependency>
3535
<dependency>
3636
<groupId>org.springframework.boot</groupId>
37-
<artifactId>spring-boot-starter-test</artifactId>
37+
<artifactId>spring-boot-starter-thymeleaf-test</artifactId>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework.boot</groupId>
42+
<artifactId>spring-boot-starter-webmvc-test</artifactId>
3843
<scope>test</scope>
3944
</dependency>
4045
</dependencies>

0 commit comments

Comments
 (0)