refactor: 封装公共配置,降低使用复杂度

This commit is contained in:
2023-11-25 20:45:16 +08:00
parent 4a8e4e4408
commit dafb2d8f5b
9 changed files with 123 additions and 0 deletions

View File

@@ -28,6 +28,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import top.charles7c.continew.starter.core.handler.GeneralPropertySourceFactory;
import top.charles7c.continew.starter.json.jackson.serializer.BigNumberSerializer;
import java.math.BigInteger;
@@ -45,6 +47,7 @@ import java.util.TimeZone;
*/
@Slf4j
@AutoConfiguration
@PropertySource(value = "classpath:default-json-jackson.yml", factory = GeneralPropertySourceFactory.class)
public class JacksonAutoConfiguration {
@Bean

View File

@@ -0,0 +1,21 @@
--- ### Spring 配置
spring:
## MVC 配置
mvc:
format:
# 日期格式化(针对 java.util.Date
date-time: yyyy-MM-dd HH:mm:ss
## Jackson 配置
jackson:
# 时区配置
time-zone: GMT+8
# 日期格式化(针对 java.util.Date
date-format: yyyy-MM-dd HH:mm:ss
# 序列化配置Bean -> JSON
serialization:
# 允许序列化无属性的 Bean
FAIL_ON_EMPTY_BEANS: false
# 反序列化配置JSON -> Bean
deserialization:
# 允许反序列化不存在的属性
FAIL_ON_UNKNOWN_PROPERTIES: false