Skip to content

Commit 07766de

Browse files
authored
Merge pull request #47 from devondragon/issue-46-Upgrade-to-Spring-Boot-4
Issue 46 upgrade to spring boot 4
2 parents 03e7f13 + a7d2582 commit 07766de

30 files changed

Lines changed: 60 additions & 71 deletions

build.gradle

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java'
3-
id 'org.springframework.boot' version '3.5.6'
3+
id 'org.springframework.boot' version '4.0.0'
44
id 'io.spring.dependency-management' version '1.1.7'
55
id "com.github.ben-manes.versions" version "0.52.0"
66

@@ -11,7 +11,7 @@ version = '1.0.1-SNAPSHOT'
1111

1212
java {
1313
toolchain {
14-
languageVersion = JavaLanguageVersion.of(17)
14+
languageVersion = JavaLanguageVersion.of(21)
1515
}
1616
}
1717

@@ -39,8 +39,8 @@ repositories {
3939

4040
dependencies {
4141
// DigitalSanctuary Spring User Framework
42-
implementation 'com.digitalsanctuary:ds-spring-user-framework:3.5.1'
43-
l
42+
implementation 'com.digitalsanctuary:ds-spring-user-framework:4.0.0'
43+
4444
// Spring Boot starters
4545
implementation 'org.springframework.boot:spring-boot-starter-actuator'
4646
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
@@ -51,8 +51,8 @@ l
5151
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
5252
implementation 'org.springframework.boot:spring-boot-starter-web'
5353

54-
// Thymeleaf extras
55-
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.3.RELEASE'
54+
// Thymeleaf extras - Spring Boot 4 manages the version
55+
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
5656
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.4.0'
5757

5858
// OpenAPI (Swagger)
@@ -78,6 +78,9 @@ l
7878

7979
// Testing dependencies
8080
testImplementation 'org.springframework.boot:spring-boot-starter-test'
81+
testImplementation 'org.springframework.boot:spring-boot-data-jpa-test'
82+
testImplementation 'org.springframework.boot:spring-boot-webmvc-test'
83+
testImplementation 'org.springframework.boot:spring-boot-starter-security-test'
8184
testImplementation 'org.springframework.security:spring-security-test'
8285
testImplementation 'com.h2database:h2:2.3.232'
8386
testImplementation 'com.codeborne:selenide:7.10.0'
@@ -112,9 +115,7 @@ tasks.register('uiTest', Test) {
112115

113116

114117
bootJar {
115-
launchScript {
116-
properties 'confFolder': '/opt/app/conf/'
117-
}
118+
// launchScript removed in Spring Boot 4 - use systemd or other init systems instead
118119
}
119120

120121
bootRun {

src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ user:
117117
bcryptStrength: 12 # The bcrypt strength to use for password hashing. The higher the number, the longer it takes to hash the password. The default is 12. The minimum is 4. The maximum is 31.
118118
testHashTime: true # If true, the test hash time will be logged to the console on startup. This is useful for determining the optimal bcryptStrength value.
119119
defaultAction: deny # The default action for all requests. This can be either deny or allow.
120-
unprotectedURIs: /,/index.html,/favicon.ico,/apple-touch-icon-precomposed.png,/css/*,/js/*,/js/user/*,/js/event/*,/img/**,/user/registration,/user/resendRegistrationToken,/user/resetPassword,/user/registrationConfirm,/user/changePassword,/user/savePassword,/oauth2/authorization/*,/login,/user/login,/user/login.html,/swagger-ui.html,/swagger-ui/**,/v3/api-docs/**,/event/,/event/list.html,/event/**,/about.html,error.htmla # A comma delimited list of URIs that should not be protected by Spring Security if the defaultAction is deny.
120+
unprotectedURIs: /,/index.html,/favicon.ico,/apple-touch-icon-precomposed.png,/css/*,/js/*,/js/user/*,/js/event/*,/img/**,/user/registration,/user/resendRegistrationToken,/user/resetPassword,/user/registrationConfirm,/user/changePassword,/user/savePassword,/oauth2/authorization/*,/login,/user/login,/user/login.html,/swagger-ui.html,/swagger-ui/**,/v3/api-docs/**,/event/,/event/list.html,/event/**,/about.html,/error,/error.html # A comma delimited list of URIs that should not be protected by Spring Security if the defaultAction is deny.
121121
protectedURIs: /protected.html # A comma delimited list of URIs that should be protected by Spring Security if the defaultAction is allow.
122122
disableCSRFdURIs: /no-csrf-test # A comma delimited list of URIs that should not be protected by CSRF protection. This may include API endpoints that need to be called without a CSRF token.
123123

src/test/java/com/digitalsanctuary/spring/demo/DemoTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.digitalsanctuary.spring.demo;
22

33
import org.junit.jupiter.api.Test;
4-
import org.springframework.boot.autoconfigure.domain.EntityScan;
4+
import org.springframework.boot.persistence.autoconfigure.EntityScan;
55
import org.springframework.boot.test.context.SpringBootTest;
66
import org.springframework.context.annotation.Import;
77
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

src/test/java/com/digitalsanctuary/spring/demo/event/EventAPIControllerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.junit.jupiter.api.BeforeEach;
2525
import org.junit.jupiter.api.Test;
2626
import org.springframework.beans.factory.annotation.Autowired;
27-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
27+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
2828
import org.springframework.test.context.bean.override.mockito.MockitoBean;
2929
import org.springframework.http.MediaType;
3030
import com.digitalsanctuary.spring.demo.SecurityTestUtils;
@@ -53,8 +53,8 @@ public class EventAPIControllerTest {
5353
@MockitoBean
5454
private DemoSessionProfile demoSessionProfile;
5555

56-
@Autowired
57-
private ObjectMapper objectMapper;
56+
private ObjectMapper objectMapper = new ObjectMapper()
57+
.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule());
5858

5959
private Event testEvent;
6060
private List<Event> testEvents;

src/test/java/com/digitalsanctuary/spring/demo/event/EventControllerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.junit.jupiter.api.BeforeEach;
1515
import org.junit.jupiter.api.Test;
1616
import org.springframework.beans.factory.annotation.Autowired;
17-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
17+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
1818
import org.springframework.http.MediaType;
1919
import org.springframework.test.context.ActiveProfiles;
2020
import org.springframework.test.context.bean.override.mockito.MockitoBean;
@@ -40,8 +40,8 @@ public class EventControllerTest {
4040
@MockitoBean
4141
private DemoUserProfileService demoUserProfileService; // Add this mock bean
4242

43-
@Autowired
44-
private ObjectMapper objectMapper;
43+
private ObjectMapper objectMapper = new ObjectMapper()
44+
.registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule());
4545

4646
private Event event;
4747

src/test/java/com/digitalsanctuary/spring/demo/event/EventRepositoryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import java.util.Optional;
88
import org.junit.jupiter.api.Test;
99
import org.springframework.beans.factory.annotation.Autowired;
10-
import org.springframework.boot.autoconfigure.domain.EntityScan;
11-
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
10+
import org.springframework.boot.persistence.autoconfigure.EntityScan;
11+
import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest;
1212
import org.springframework.test.context.ActiveProfiles;
1313

1414
@ActiveProfiles("test")

src/test/java/com/digitalsanctuary/spring/user/UserApplicationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.digitalsanctuary.spring.user;
22

3-
import org.springframework.boot.autoconfigure.domain.EntityScan;
3+
import org.springframework.boot.persistence.autoconfigure.EntityScan;
44
import org.springframework.boot.test.context.SpringBootTest;
55
import org.springframework.context.annotation.Import;
66
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

src/test/java/com/digitalsanctuary/spring/user/api/ApiSecurityTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.junit.jupiter.api.Nested;
1414
import org.junit.jupiter.api.Test;
1515
import org.springframework.beans.factory.annotation.Autowired;
16-
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
16+
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
1717
import org.springframework.boot.test.context.SpringBootTest;
1818
import org.springframework.http.MediaType;
1919
import org.springframework.security.test.context.support.WithAnonymousUser;
@@ -52,8 +52,7 @@ class ApiSecurityTest {
5252
@Autowired
5353
private MockMvc mockMvc;
5454

55-
@Autowired
56-
private ObjectMapper objectMapper;
55+
private ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule());
5756

5857
@Autowired
5958
private UserRepository userRepository;

src/test/java/com/digitalsanctuary/spring/user/api/AuthenticatedUserApiTestSimplified.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.junit.jupiter.api.Disabled;
1616
import org.springframework.beans.factory.annotation.Autowired;
1717
import org.springframework.beans.factory.annotation.Value;
18-
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
18+
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
1919
import org.springframework.boot.test.context.SpringBootTest;
2020
import org.springframework.http.MediaType;
2121
import org.springframework.security.core.authority.SimpleGrantedAuthority;
@@ -57,8 +57,7 @@ class AuthenticatedUserApiTestSimplified {
5757
@Autowired
5858
private MockMvc mockMvc;
5959

60-
@Autowired
61-
private ObjectMapper objectMapper;
60+
private ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule());
6261

6362
@Autowired
6463
private UserRepository userRepository;

src/test/java/com/digitalsanctuary/spring/user/api/PasswordResetApiTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.junit.jupiter.api.DisplayName;
2626
import org.junit.jupiter.api.Test;
2727
import org.springframework.beans.factory.annotation.Autowired;
28-
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
28+
import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc;
2929
import org.springframework.boot.test.context.SpringBootTest;
3030
import org.springframework.http.MediaType;
3131
import org.springframework.test.context.ActiveProfiles;
@@ -67,8 +67,7 @@ class PasswordResetApiTest {
6767
@Autowired
6868
private MockMvc mockMvc;
6969

70-
@Autowired
71-
private ObjectMapper objectMapper;
70+
private ObjectMapper objectMapper = new ObjectMapper().registerModule(new com.fasterxml.jackson.datatype.jsr310.JavaTimeModule());
7271

7372
@Autowired
7473
private UserRepository userRepository;

0 commit comments

Comments
 (0)