-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor:
configure()
을 JsonMapper.builder().configure(...)
로 변경 및…
… 적용 위치 이동 - `configure()` Deprecated. Since 2.13 use JsonMapper.builder().configure(...) 에 따라 리팩토링. - 직렬화, 역직렬화, 매퍼 설정을 Hal 설정 클래스에서 Serialize 설정 클래스로 이동.
- Loading branch information
Showing
2 changed files
with
10 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
...va/com/shacomiro/nesonnechek/api/global/config/jackson/JacksonSerializeConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
package com.shacomiro.nesonnechek.api.global.config.jackson; | ||
|
||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.core.authority.SimpleGrantedAuthority; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.MapperFeature; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | ||
import com.shacomiro.nesonnechek.api.global.security.deserializer.SimpleGrantedAuthorityDeserializer; | ||
|
||
@Configuration | ||
public class JacksonSerializeConfiguration { | ||
|
||
public JacksonSerializeConfiguration(ObjectMapper objectMapper) { | ||
SimpleModule grantedAuthorityDeserializeModule = new SimpleModule() | ||
.addDeserializer(SimpleGrantedAuthority.class, new SimpleGrantedAuthorityDeserializer()); | ||
objectMapper.registerModule(grantedAuthorityDeserializeModule); | ||
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true); | ||
@Bean | ||
public Jackson2ObjectMapperBuilderCustomizer customizer() { | ||
return builder -> builder.deserializerByType(SimpleGrantedAuthority.class, new SimpleGrantedAuthorityDeserializer()) | ||
.featuresToEnable(SerializationFeature.INDENT_OUTPUT) | ||
.featuresToEnable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | ||
.featuresToEnable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS); | ||
} | ||
} |