【底座】启动配置增加应用名称,底座增加traceId机制;

This commit is contained in:
dongxiayu
2025-06-08 23:16:32 +08:00
parent a4d45fab44
commit 936ce722e8
7 changed files with 196 additions and 2 deletions

View File

@@ -66,6 +66,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import vip.xiaonuo.auth.core.util.StpClientUtil;
@@ -74,6 +75,7 @@ import vip.xiaonuo.common.annotation.CommonWrapper;
import vip.xiaonuo.common.cache.CommonCacheOperator;
import vip.xiaonuo.common.enums.CommonDeleteFlagEnum;
import vip.xiaonuo.common.exception.CommonException;
import vip.xiaonuo.common.interceptor.CommonTraceInterceptor;
import vip.xiaonuo.common.listener.CommonDataChangeEventCenter;
import vip.xiaonuo.common.listener.CommonDataChangeListener;
import vip.xiaonuo.common.pojo.CommonResult;
@@ -702,4 +704,14 @@ public class GlobalConfigure implements WebMvcConfigurer {
public void registerListenerList(List<CommonDataChangeListener> dataChangeListenerList) {
CommonDataChangeEventCenter.registerListenerList(dataChangeListenerList);
}
/**
* 添加应用拦截器
* @param registry
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 注册注解拦截器,并排除不需要注解鉴权的接口地址 (与登录拦截器无关,只是说明哪些接口不需要被拦截器拦截,此处都拦截)
registry.addInterceptor(new CommonTraceInterceptor()).addPathPatterns("/**");
}
}

View File

@@ -2,6 +2,7 @@
# server configuration
#########################################
server.port=82
spring.application.name=snowy
#########################################
# spring allow-circular-references
@@ -27,9 +28,9 @@ spring.servlet.multipart.max-file-size=100MB
# mysql
spring.datasource.dynamic.datasource.master.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.dynamic.datasource.master.url=jdbc:mysql://localhost:3306/snowy?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&useInformationSchema=true&rewriteBatchedStatements=true
spring.datasource.dynamic.datasource.master.url=jdbc:mysql://localhost:3306/snowy3-gitee?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&useInformationSchema=true&rewriteBatchedStatements=true
spring.datasource.dynamic.datasource.master.username=root
spring.datasource.dynamic.datasource.master.password=12345678
spring.datasource.dynamic.datasource.master.password=123456
spring.datasource.dynamic.strict=true
# postgres

View File

@@ -4,6 +4,10 @@
<!--日志格式应用spring boot默认的格式也可以自己更改-->
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<!-- 注册自定义转换器 -->
<conversionRule conversionWord="tid" converterClass="vip.xiaonuo.common.aspect.CustomTraceIdConverter" />
<!--定义日志存放的位置,默认存放在项目启动的相对路径的目录-->
<springProperty scope="context" name="LOG_PATH" source="log.path" defaultValue="app-log"/>