feat: 添加UTF-8编码支持并优化DTO验证
refactor: 重构用户服务密码更新逻辑 fix: 删除不再使用的MarkdownDto类 style: 清理日志文件并优化日志配置 build: 更新pom.xml配置以支持UTF-8编码 docs: 更新application.properties配置文档
This commit is contained in:
@@ -3,11 +3,40 @@ package com.qf.myafterprojecy;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* 应用主类
|
||||
* 设置系统编码并启动Spring Boot应用
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class MyAfterProjecyApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 在应用启动前设置系统编码,确保所有输出都使用UTF-8
|
||||
setSystemEncoding();
|
||||
|
||||
// 启动Spring Boot应用
|
||||
SpringApplication.run(MyAfterProjecyApplication.class, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置系统编码为UTF-8
|
||||
* 解决控制台输出和日志中的中文乱码问题
|
||||
*/
|
||||
private static void setSystemEncoding() {
|
||||
// 设置系统属性,确保所有输出流都使用UTF-8编码
|
||||
System.setProperty("file.encoding", StandardCharsets.UTF_8.name());
|
||||
System.setProperty("sun.stdout.encoding", StandardCharsets.UTF_8.name());
|
||||
System.setProperty("sun.stderr.encoding", StandardCharsets.UTF_8.name());
|
||||
|
||||
// 设置默认字符编码
|
||||
try {
|
||||
java.nio.charset.Charset.defaultCharset();
|
||||
} catch (Exception e) {
|
||||
// 记录编码设置异常
|
||||
System.err.println("设置默认字符编码时发生异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user