Skip to content

Commit db89cc4

Browse files
authored
update to spring boot 4 and fix update issues (#42)
* update to spring boot 4
1 parent 6ac1a28 commit db89cc4

File tree

15 files changed

+267
-117
lines changed

15 files changed

+267
-117
lines changed

pom.xml

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<parent>
67
<groupId>org.springframework.boot</groupId>
78
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.5.7</version>
9+
<version>4.0.0</version>
910
<relativePath/> <!-- lookup parent from repository -->
1011
</parent>
1112

@@ -52,7 +53,7 @@
5253
<dependency>
5354
<groupId>io.github.classgraph</groupId>
5455
<artifactId>classgraph</artifactId>
55-
<version>4.8.181</version>
56+
<version>4.8.184</version>
5657
</dependency>
5758

5859

@@ -61,7 +62,7 @@
6162
<dependency>
6263
<groupId>commons-validator</groupId>
6364
<artifactId>commons-validator</artifactId>
64-
<version>1.10.0</version>
65+
<version>1.10.1</version>
6566
<exclusions>
6667
<exclusion>
6768
<groupId>commons-collections</groupId>
@@ -78,7 +79,7 @@
7879
<dependency>
7980
<groupId>org.springdoc</groupId>
8081
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
81-
<version>2.8.14</version>
82+
<version>3.0.0</version>
8283
</dependency>
8384

8485
<!-- Testing -->
@@ -98,13 +99,18 @@
9899
<artifactId>spring-boot-starter-web</artifactId>
99100
<scope>test</scope>
100101
</dependency>
101-
102-
<!-- Database -->
103102
<dependency>
104-
<groupId>org.liquibase</groupId>
105-
<artifactId>liquibase-core</artifactId>
103+
<groupId>org.springframework.boot</groupId>
104+
<artifactId>spring-boot-webmvc-test</artifactId>
105+
<scope>test</scope>
106+
</dependency>
107+
<dependency>
108+
<groupId>org.springframework.boot</groupId>
109+
<artifactId>spring-boot-starter-liquibase</artifactId>
106110
<scope>test</scope>
107111
</dependency>
112+
113+
<!-- Database -->
108114
<dependency>
109115
<groupId>org.postgresql</groupId>
110116
<artifactId>postgresql</artifactId>
@@ -117,22 +123,6 @@
117123
<artifactId>testcontainers</artifactId>
118124
<version>2.0.2</version>
119125
<scope>test</scope>
120-
<exclusions>
121-
<exclusion>
122-
<groupId>org.hamcrest</groupId>
123-
<artifactId>hamcrest-core</artifactId>
124-
</exclusion>
125-
<exclusion>
126-
<groupId>org.hamcrest</groupId>
127-
<artifactId>hamcrest-library</artifactId>
128-
</exclusion>
129-
<exclusion>
130-
<!-- see: https://github.com/testcontainers/testcontainers-java/issues/970#issuecomment-625044008 -->
131-
<!-- can be removed once testcontainers drop their dependency to junit4 -->
132-
<groupId>junit</groupId>
133-
<artifactId>junit</artifactId>
134-
</exclusion>
135-
</exclusions>
136126
</dependency>
137127
<dependency>
138128
<groupId>org.testcontainers</groupId>
@@ -195,12 +185,12 @@
195185
<dependency>
196186
<groupId>com.puppycrawl.tools</groupId>
197187
<artifactId>checkstyle</artifactId>
198-
<version>11.1.0</version>
188+
<version>12.3.0</version>
199189
</dependency>
200190
<dependency>
201191
<groupId>it.aboutbits</groupId>
202192
<artifactId>java-checkstyle-config</artifactId>
203-
<version>1.0.1</version>
193+
<version>1.1.0</version>
204194
</dependency>
205195
</dependencies>
206196
</plugin>

src/main/java/it/aboutbits/springboot/toolbox/autoconfiguration/web/CustomTypeConfiguration.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
import it.aboutbits.springboot.toolbox.type.identity.EntityId;
88
import it.aboutbits.springboot.toolbox.web.CustomTypePropertyEditor;
99
import it.aboutbits.springboot.toolbox.web.EntityIdPropertyEditor;
10-
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
10+
import org.springframework.boot.jackson.autoconfigure.JsonMapperBuilderCustomizer;
1111
import org.springframework.context.annotation.Bean;
1212
import org.springframework.context.annotation.Configuration;
1313
import org.springframework.web.bind.WebDataBinder;
1414
import org.springframework.web.bind.annotation.ControllerAdvice;
1515
import org.springframework.web.bind.annotation.InitBinder;
16+
import tools.jackson.databind.module.SimpleModule;
1617

1718
import java.util.Set;
1819

@@ -37,19 +38,23 @@ public void initBinder(WebDataBinder binder) {
3738
}
3839

3940
@Bean
40-
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuration) {
41-
var types = configuration.getRelevantTypes();
41+
public JsonMapperBuilderCustomizer jsonCustomizer(CustomTypeScanner configuration) {
42+
var module = new SimpleModule();
4243

43-
var deserializers = types.stream()
44-
.map(CustomTypeDeserializer::new)
45-
.toList()
46-
.toArray(new CustomTypeDeserializer[types.size()]);
44+
// serializers
45+
module.addSerializer(new CustomTypeSerializer());
4746

47+
// dynamic deserializers
48+
configuration.getRelevantTypes()
49+
.forEach(type ->
50+
module.addDeserializer(type, new CustomTypeDeserializer(type))
51+
);
52+
53+
// type-based deserializer
54+
module.addDeserializer(EntityId.class, new EntityIdDeserializer());
4855

4956
return builder -> builder
50-
.serializers(new CustomTypeSerializer())
51-
.deserializers(deserializers)
52-
.deserializerByType(EntityId.class, new EntityIdDeserializer());
57+
.addModule(module);
5358
}
5459

5560
}

src/main/java/it/aboutbits/springboot/toolbox/exception/ExceptionMessageDefinition.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
* <p>
77
* Example:
88
* {@snippet :
9+
*
910
* @Getter
1011
* @Accessors(fluent = true)
11-
* @RequiredArgsConstructor
12-
* enum MyExceptionMessages implements ExceptionMessageDefinition {
13-
* SHARED_ERROR_GENERAL("shared.error.general");
14-
*
15-
* private final String code;
16-
* }
12+
* @RequiredArgsConstructor enum MyExceptionMessages implements ExceptionMessageDefinition {
13+
* SHARED_ERROR_GENERAL("shared.error.general");
14+
* <p>
15+
* private final String code;
1716
* }
17+
*}
1818
*/
1919
public interface ExceptionMessageDefinition {
2020
String code();

0 commit comments

Comments
 (0)