服务启动

This commit is contained in:
2025-12-05 18:24:21 +08:00
parent a8233ceb72
commit 133209691e
39 changed files with 2526 additions and 30 deletions

View File

@@ -13,7 +13,6 @@
<artifactId>common-utils</artifactId>
<version>${urban-lifeline.version}</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
@@ -44,5 +43,22 @@
<artifactId>spring-boot-starter</artifactId>
<scope>provided</scope>
</dependency>
<!-- Spring Mail for Email -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- Aliyun SMS Service -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>dysmsapi20170525</artifactId>
<version>4.2.0</version>
</dependency>
<!-- FastJson2 Spring6 支持 -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring6</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,50 @@
package org.xyzh.common.utils.config;
import com.alibaba.fastjson2.support.config.FastJsonConfig;
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.List;
/**
* @description FastJson配置类 - 统一处理日期时间格式序列化
* @filename FastJsonConfig.java
* @author yslg
* @copyright xyzh
* @since 2025-11-28
*/
@Configuration
public class FastJsonConfiguration implements WebMvcConfigurer {
/**
* 配置FastJson消息转换器
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
// FastJson配置
FastJsonConfig config = new FastJsonConfig();
// 设置日期格式
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
// 设置字符集
converter.setDefaultCharset(StandardCharsets.UTF_8);
// 设置支持的MediaType
converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
// 应用配置
converter.setFastJsonConfig(config);
// 添加到转换器列表(添加到最前面,优先使用)
converters.add(0, converter);
}
}