From 8ff153cafc033cbb7f613c96599785250e09d511 Mon Sep 17 00:00:00 2001 From: Tom Winter Date: Tue, 10 Dec 2024 14:25:34 +0100 Subject: [PATCH] fix: ObjectMapperConfiguration --- .../rest/ObjectMapperConfiguration.kt | 24 +++++++------------ .../src/main/resources/application.yaml | 2 ++ .../src/test/resources/application-e2e.yaml | 1 + 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/rest/ObjectMapperConfiguration.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/rest/ObjectMapperConfiguration.kt index 37e4ee0..15342d8 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/rest/ObjectMapperConfiguration.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/rest/ObjectMapperConfiguration.kt @@ -2,7 +2,6 @@ package com.aamdigital.aambackendservice.rest import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.ObjectMapper -import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Primary @@ -10,22 +9,15 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder @Configuration class ObjectMapperConfiguration { - - @Bean - fun jsonCustomizer(): Jackson2ObjectMapperBuilderCustomizer { - return Jackson2ObjectMapperBuilderCustomizer { builder: Jackson2ObjectMapperBuilder -> - builder.featuresToEnable( - DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, - DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE, - ) - } - } - + @Bean @Primary - fun objectMapper(jsonCustomizer: Jackson2ObjectMapperBuilderCustomizer): ObjectMapper { - val builder = Jackson2ObjectMapperBuilder() - jsonCustomizer.customize(builder) - return builder.build() + fun objectMapper(): ObjectMapper { + val mapper = Jackson2ObjectMapperBuilder() + mapper.featuresToEnable( + DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, + DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE + ) + return mapper.build() } } diff --git a/application/aam-backend-service/src/main/resources/application.yaml b/application/aam-backend-service/src/main/resources/application.yaml index d245ac3..1721521 100644 --- a/application/aam-backend-service/src/main/resources/application.yaml +++ b/application/aam-backend-service/src/main/resources/application.yaml @@ -3,6 +3,7 @@ spring: name: aam-backend-service main: banner-mode: off + allow-bean-definition-overriding: true rabbitmq: listener: simple: @@ -20,6 +21,7 @@ spring: multipart: max-file-size: 5MB + server: servlet: context-path: /api diff --git a/application/aam-backend-service/src/test/resources/application-e2e.yaml b/application/aam-backend-service/src/test/resources/application-e2e.yaml index 2b18c1f..6ec8591 100644 --- a/application/aam-backend-service/src/test/resources/application-e2e.yaml +++ b/application/aam-backend-service/src/test/resources/application-e2e.yaml @@ -3,6 +3,7 @@ spring: name: aam-backend-service main: banner-mode: off + allow-bean-definition-overriding: true rabbitmq: listener: simple: