Skip to content

Commit c0b9fbb

Browse files
committed
feat: Spring Boot 4
1 parent d9423aa commit c0b9fbb

File tree

11 files changed

+121
-56
lines changed

11 files changed

+121
-56
lines changed

backend/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<attribute name="optional" value="true"/>
77
</attributes>
88
</classpathentry>
9-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-24">
9+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25">
1010
<attributes>
1111
<attribute name="maven.pomderived" value="true"/>
1212
</attributes>

backend/pom.xml

Lines changed: 104 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,94 @@ the specific language governing permissions and limitations under the License. -
2828
</license>
2929
</licenses>
3030
<dependencies>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-actuator</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework.boot</groupId>
41+
<artifactId>spring-boot-starter-webmvc</artifactId>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-mail</artifactId>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-starter-security</artifactId>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.springframework.boot</groupId>
53+
<artifactId>spring-boot-starter-validation</artifactId>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.springframework.boot</groupId>
57+
<artifactId>spring-boot-starter-webclient</artifactId>
58+
</dependency>
59+
<dependency>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-starter-webflux</artifactId>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-starter-websocket</artifactId>
66+
</dependency>
67+
68+
<dependency>
69+
<groupId>io.micrometer</groupId>
70+
<artifactId>micrometer-registry-prometheus</artifactId>
71+
<scope>runtime</scope>
72+
</dependency>
73+
<dependency>
74+
<groupId>org.springframework.boot</groupId>
75+
<artifactId>spring-boot-starter-actuator-test</artifactId>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.springframework.boot</groupId>
80+
<artifactId>spring-boot-starter-data-mongodb-reactive-test</artifactId>
81+
<scope>test</scope>
82+
</dependency>
83+
<dependency>
84+
<groupId>org.springframework.boot</groupId>
85+
<artifactId>spring-boot-starter-mail-test</artifactId>
86+
<scope>test</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>org.springframework.boot</groupId>
90+
<artifactId>spring-boot-starter-security-test</artifactId>
91+
<scope>test</scope>
92+
</dependency>
93+
<dependency>
94+
<groupId>org.springframework.boot</groupId>
95+
<artifactId>spring-boot-starter-validation-test</artifactId>
96+
<scope>test</scope>
97+
</dependency>
98+
<dependency>
99+
<groupId>org.springframework.boot</groupId>
100+
<artifactId>spring-boot-starter-webclient-test</artifactId>
101+
<scope>test</scope>
102+
</dependency>
103+
<dependency>
104+
<groupId>org.springframework.boot</groupId>
105+
<artifactId>spring-boot-starter-webflux-test</artifactId>
106+
<scope>test</scope>
107+
</dependency>
108+
<dependency>
109+
<groupId>org.springframework.boot</groupId>
110+
<artifactId>spring-boot-starter-webmvc-test</artifactId>
111+
<scope>test</scope>
112+
</dependency>
113+
<dependency>
114+
<groupId>org.springframework.boot</groupId>
115+
<artifactId>spring-boot-starter-websocket-test</artifactId>
116+
<scope>test</scope>
117+
</dependency>
118+
<!--
31119
<dependency>
32120
<groupId>org.springframework.boot</groupId>
33121
<artifactId>spring-boot-starter-integration</artifactId>
@@ -60,22 +148,10 @@ the specific language governing permissions and limitations under the License. -
60148
<groupId>org.springframework.boot</groupId>
61149
<artifactId>spring-boot-starter-actuator</artifactId>
62150
</dependency>
63-
<dependency>
64-
<groupId>org.springframework.ai</groupId>
65-
<artifactId>spring-ai-starter-model-chat-memory</artifactId>
66-
</dependency>
67151
<dependency>
68152
<groupId>org.springframework.boot</groupId>
69153
<artifactId>spring-boot-starter-validation</artifactId>
70154
</dependency>
71-
<dependency>
72-
<groupId>org.springframework.ai</groupId>
73-
<artifactId>spring-ai-starter-model-ollama</artifactId>
74-
</dependency>
75-
<dependency>
76-
<groupId>org.springframework.ai</groupId>
77-
<artifactId>spring-ai-retry</artifactId>
78-
</dependency>
79155
<dependency>
80156
<groupId>io.micrometer</groupId>
81157
<artifactId>micrometer-registry-prometheus</artifactId>
@@ -86,6 +162,20 @@ the specific language governing permissions and limitations under the License. -
86162
<artifactId>spring-boot-starter-test</artifactId>
87163
<scope>test</scope>
88164
</dependency>
165+
-->
166+
<dependency>
167+
<groupId>org.springframework.ai</groupId>
168+
<artifactId>spring-ai-starter-model-chat-memory</artifactId>
169+
</dependency>
170+
<dependency>
171+
<groupId>org.springframework.ai</groupId>
172+
<artifactId>spring-ai-starter-model-ollama</artifactId>
173+
</dependency>
174+
<dependency>
175+
<groupId>org.springframework.ai</groupId>
176+
<artifactId>spring-ai-retry</artifactId>
177+
</dependency>
178+
<!--
89179
<dependency>
90180
<groupId>io.projectreactor</groupId>
91181
<artifactId>reactor-test</artifactId>
@@ -95,7 +185,8 @@ the specific language governing permissions and limitations under the License. -
95185
<groupId>org.springframework.security</groupId>
96186
<artifactId>spring-security-test</artifactId>
97187
<scope>test</scope>
98-
</dependency>
188+
</dependency>
189+
-->
99190
<dependency>
100191
<groupId>net.javacrumbs.shedlock</groupId>
101192
<artifactId>shedlock-spring</artifactId>

backend/src/main/java/ch/xxx/messenger/adapter/config/GlobalErrorWebExceptionHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
package ch.xxx.messenger.adapter.config;
1414

1515
import org.springframework.boot.autoconfigure.web.WebProperties;
16-
import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler;
17-
import org.springframework.boot.web.reactive.error.ErrorAttributes;
16+
import org.springframework.boot.webflux.autoconfigure.error.AbstractErrorWebExceptionHandler;
17+
import org.springframework.boot.webflux.error.ErrorAttributes;
1818
import org.springframework.context.ApplicationContext;
1919
import org.springframework.core.annotation.Order;
2020
import org.springframework.http.HttpStatus;

backend/src/main/java/ch/xxx/messenger/adapter/config/SpringMongoConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import org.slf4j.Logger;
1616
import org.slf4j.LoggerFactory;
1717
import org.springframework.beans.factory.annotation.Value;
18-
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
18+
import org.springframework.boot.mongodb.autoconfigure.MongoProperties;
1919
import org.springframework.context.annotation.Bean;
2020
import org.springframework.context.annotation.Configuration;
2121
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;

backend/src/main/java/ch/xxx/messenger/adapter/config/WebSecurityConfig.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,21 @@
1212
*/
1313
package ch.xxx.messenger.adapter.config;
1414

15-
import org.springframework.boot.autoconfigure.security.SecurityProperties;
1615
import org.springframework.context.annotation.Bean;
1716
import org.springframework.context.annotation.Configuration;
18-
import org.springframework.core.annotation.Order;
1917
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
2018
import org.springframework.security.config.http.SessionCreationPolicy;
2119
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
2220
import org.springframework.security.crypto.password.PasswordEncoder;
2321
import org.springframework.security.web.SecurityFilterChain;
2422
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
2523
import org.springframework.security.web.header.writers.XXssProtectionHeaderWriter.HeaderValue;
26-
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
24+
import org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher;
2725

2826
import ch.xxx.messenger.domain.common.JwtTokenProvider;
2927
import ch.xxx.messenger.domain.common.Role;
3028

3129
@Configuration
32-
@Order(SecurityProperties.DEFAULT_FILTER_ORDER)
3330
public class WebSecurityConfig {
3431

3532
private final JwtTokenProvider jwtTokenProvider;
@@ -43,9 +40,9 @@ public SecurityFilterChain configure(HttpSecurity http) throws Exception {
4340
JwtTokenFilter customFilter = new JwtTokenFilter(jwtTokenProvider);
4441
HttpSecurity httpSecurity = http
4542
.authorizeHttpRequests(authorize -> authorize
46-
.requestMatchers(AntPathRequestMatcher.antMatcher("/rest/auth/**")).permitAll()
47-
.requestMatchers(AntPathRequestMatcher.antMatcher("/rest/**")).hasAuthority(Role.USERS.toString())
48-
.requestMatchers(AntPathRequestMatcher.antMatcher("/**")).permitAll())
43+
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/rest/auth/**")).permitAll()
44+
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/rest/**")).hasAuthority(Role.USERS.toString())
45+
.requestMatchers(PathPatternRequestMatcher.withDefaults().matcher("/**")).permitAll())
4946
.csrf(myCsrf -> myCsrf.disable())
5047
.sessionManagement(mySm -> mySm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
5148
.headers(myHeaders -> myHeaders.contentSecurityPolicy(myCsp -> myCsp.policyDirectives(

backend/src/main/java/ch/xxx/messenger/domain/exception/MyErrorAttributes.java

Lines changed: 0 additions & 21 deletions
This file was deleted.

backend/src/test/java/ch/xxx/messenger/adapter/controller/MessageControllerTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
import org.junit.jupiter.api.Test;
2828
import org.mockito.Mockito;
2929
import org.springframework.beans.factory.annotation.Autowired;
30-
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
30+
import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;
3131
import org.springframework.context.annotation.ComponentScan.Filter;
3232
import org.springframework.context.annotation.FilterType;
3333
import org.springframework.http.MediaType;
3434
import org.springframework.test.context.bean.override.mockito.MockitoBean;
3535
import org.springframework.test.util.ReflectionTestUtils;
3636
import org.springframework.test.web.servlet.MockMvc;
3737

38-
import com.fasterxml.jackson.databind.ObjectMapper;
39-
4038
import ch.xxx.messenger.adapter.config.WebSecurityConfig;
4139
import ch.xxx.messenger.domain.common.JwtTokenProvider;
4240
import ch.xxx.messenger.domain.common.Role;
@@ -45,6 +43,7 @@
4543
import ch.xxx.messenger.domain.model.SyncMsgs;
4644
import ch.xxx.messenger.usecase.service.MessageService;
4745
import reactor.core.publisher.Flux;
46+
import tools.jackson.databind.json.JsonMapper;
4847

4948
@WebMvcTest(controllers = MessageController.class, includeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
5049
WebSecurityConfig.class, JwtTokenProvider.class }))
@@ -57,7 +56,7 @@ public class MessageControllerTest {
5756
@Autowired
5857
private JwtTokenProvider jwtTokenProvider;
5958
@Autowired
60-
private ObjectMapper objectMapper;
59+
private JsonMapper objectMapper;
6160
@Autowired
6261
private MockMvc mockMvc;
6362

backend/src/test/java/ch/xxx/messenger/architecture/MyArchitectureTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import org.junit.jupiter.api.Test;
2424
import org.slf4j.Logger;
25-
import org.springframework.boot.web.reactive.error.DefaultErrorAttributes;
25+
import org.springframework.boot.webflux.error.DefaultErrorAttributes;
2626
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.scheduling.annotation.Scheduled;
2828
import org.springframework.web.bind.annotation.RestController;

backend/src/test/java/ch/xxx/messenger/usecase/service/MessageServiceTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
import org.mockito.InjectMocks;
2929
import org.mockito.Mock;
3030
import org.mockito.Mockito;
31+
import org.mockito.junit.jupiter.MockitoExtension;
3132
import org.springframework.data.mongodb.core.query.Query;
32-
import org.springframework.test.context.junit.jupiter.SpringExtension;
3333

3434
import ch.xxx.messenger.domain.model.Message;
3535
import ch.xxx.messenger.domain.model.MyMongoRepository;
3636
import ch.xxx.messenger.domain.model.SyncMsgs;
3737
import reactor.core.publisher.Flux;
3838
import reactor.core.publisher.Mono;
3939

40-
@ExtendWith(SpringExtension.class)
40+
@ExtendWith(MockitoExtension.class)
4141
public class MessageServiceTest {
4242
@Mock
4343
private MyMongoRepository myMongoRepository;
@@ -60,8 +60,7 @@ public void findMessagesFound() throws Exception {
6060
@SuppressWarnings("unchecked")
6161
@Test
6262
public void findMessagesNotFound() throws Exception {
63-
Mockito.when(this.myMongoRepository.find(isA(Query.class), any(Class.class))).thenReturn(Flux.fromIterable(List.of()));
64-
Mockito.when(this.myMongoRepository.save(isA(Message.class))).thenReturn(Mono.empty());
63+
Mockito.when(this.myMongoRepository.find(isA(Query.class), any(Class.class))).thenReturn(Flux.fromIterable(List.of()));
6564
SyncMsgs mySyncMsgs = this.createSyncMsgs();
6665
List<Message> messages = this.messageService.findMessages(mySyncMsgs).collectList().block();
6766
Assertions.assertTrue(messages.isEmpty());

frontend/.classpath

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-24">
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-25">
44
<attributes>
55
<attribute name="maven.pomderived" value="true"/>
66
</attributes>

0 commit comments

Comments
 (0)