From b153a67b7037da379d9153d13eb0ea684f1c20a7 Mon Sep 17 00:00:00 2001 From: Kamil Adam Date: Thu, 4 Apr 2024 16:43:47 +0200 Subject: [PATCH] Add Configuration --- .../pl/writeonly/omnibus/config/Config.kt | 17 +++++++++++++++++ src/main/resources/data.sql | 1 + src/main/resources/schema.sql | 5 +++++ 3 files changed, 23 insertions(+) create mode 100644 src/main/kotlin/pl/writeonly/omnibus/config/Config.kt create mode 100644 src/main/resources/data.sql create mode 100644 src/main/resources/schema.sql diff --git a/src/main/kotlin/pl/writeonly/omnibus/config/Config.kt b/src/main/kotlin/pl/writeonly/omnibus/config/Config.kt new file mode 100644 index 0000000..b3c8dbe --- /dev/null +++ b/src/main/kotlin/pl/writeonly/omnibus/config/Config.kt @@ -0,0 +1,17 @@ +package pl.writeonly.omnibus.config + +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.databind.ObjectMapper +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.annotation.Configuration + +@Configuration +class Config { + + @Autowired + private lateinit var objectMapper: ObjectMapper + + fun customizeObjectMapper() { + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + } +} \ No newline at end of file diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql new file mode 100644 index 0000000..4961e4d --- /dev/null +++ b/src/main/resources/data.sql @@ -0,0 +1 @@ +INSERT INTO post(id, title, content) VALUES (1, 'Test post 1', 'Content1'); diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql new file mode 100644 index 0000000..edb6a7a --- /dev/null +++ b/src/main/resources/schema.sql @@ -0,0 +1,5 @@ +CREATE TABLE post ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + title VARCHAR(400) NOT NULL, + content VARCHAR(2000) NULL +); \ No newline at end of file