mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 02:08:43 +08:00 
			
		
		
		
	项目结构调整 x 18 : 解决拆分后的报错
This commit is contained in:
		| @@ -29,7 +29,7 @@ public class WebProperties { | ||||
|      * | ||||
|      * 主要目的是,给该 Controller 设置指定的 {@link #apiPrefix} | ||||
|      * | ||||
|      * 因为我们有多个 modules 包里会包含 Controller,所以只需要写到 cn.iocoder.dashboard 这样的层级 | ||||
|      * 因为我们有多个 modules 包里会包含 Controller,所以只需要写到 cn.iocoder.yudao 这样的层级 | ||||
|      */ | ||||
|     @NotNull(message = "Controller 所在包不能为空") | ||||
|     private String controllerPackage; | ||||
|   | ||||
| @@ -1,9 +1,13 @@ | ||||
| package cn.iocoder.yudao.framework.web.config; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLogFrameworkService; | ||||
| import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum; | ||||
| import cn.iocoder.yudao.framework.web.core.filter.CacheRequestBodyFilter; | ||||
| import cn.iocoder.yudao.framework.web.core.filter.DemoFilter; | ||||
| import cn.iocoder.yudao.framework.web.core.filter.XssFilter; | ||||
| import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler; | ||||
| import cn.iocoder.yudao.framework.web.core.handler.GlobalResponseBodyHandler; | ||||
| import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||||
| import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||||
| @@ -26,6 +30,11 @@ public class YudaoWebAutoConfiguration implements WebMvcConfigurer { | ||||
|  | ||||
|     @Resource | ||||
|     private WebProperties webProperties; | ||||
|     /** | ||||
|      * 应用名 | ||||
|      */ | ||||
|     @Value("${spring.application.name}") | ||||
|     private String applicationName; | ||||
|  | ||||
|     @Override | ||||
|     public void configurePathMatch(PathMatchConfigurer configurer) { | ||||
| @@ -35,6 +44,16 @@ public class YudaoWebAutoConfiguration implements WebMvcConfigurer { | ||||
|                 && clazz.getPackage().getName().startsWith(webProperties.getControllerPackage())); // 仅仅匹配 controller 包 | ||||
|     } | ||||
|  | ||||
|     @Bean | ||||
|     public GlobalExceptionHandler globalExceptionHandler(ApiErrorLogFrameworkService ApiErrorLogFrameworkService) { | ||||
|         return new GlobalExceptionHandler(applicationName, ApiErrorLogFrameworkService); | ||||
|     } | ||||
|  | ||||
|     @Bean | ||||
|     public GlobalResponseBodyHandler globalResponseBodyHandler() { | ||||
|         return new GlobalResponseBodyHandler(); | ||||
|     } | ||||
|  | ||||
|     // ========== Filter 相关 ========== | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | ||||
| import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; | ||||
| import io.github.resilience4j.ratelimiter.RequestNotPermitted; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.exception.ExceptionUtils; | ||||
| import org.springframework.beans.factory.annotation.Value; | ||||
| @@ -43,14 +44,13 @@ import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeC | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @RestControllerAdvice | ||||
| @AllArgsConstructor | ||||
| @Slf4j | ||||
| public class GlobalExceptionHandler { | ||||
|  | ||||
|     @Value("${spring.application.name}") | ||||
|     private String applicationName; | ||||
|     private final String applicationName; | ||||
|  | ||||
|     @Resource | ||||
|     private ApiErrorLogFrameworkService apiErrorLogFrameworkService; | ||||
|     private final ApiErrorLogFrameworkService apiErrorLogFrameworkService; | ||||
|  | ||||
|     /** | ||||
|      * 处理所有异常,主要是提供给 Filter 使用 | ||||
|   | ||||
| @@ -0,0 +1,5 @@ | ||||
| org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||||
|   cn.iocoder.yudao.framework.apilog.config.YudaoApiLogAutoConfiguration,\ | ||||
|   cn.iocoder.yudao.framework.jackson.config.YudaoJacksonAutoConfiguration,\ | ||||
|   cn.iocoder.yudao.framework.swagger.config.YudaoSwaggerAutoConfiguration,\ | ||||
|   cn.iocoder.yudao.framework.web.config.YudaoWebAutoConfiguration | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV