mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
修复 swagger 404 的问题
This commit is contained in:
parent
f6420e301e
commit
969b9c3458
@ -168,12 +168,6 @@ public class GlobalExceptionHandler {
|
|||||||
*/
|
*/
|
||||||
@ExceptionHandler(NoHandlerFoundException.class)
|
@ExceptionHandler(NoHandlerFoundException.class)
|
||||||
public CommonResult<?> noHandlerFoundExceptionHandler(HttpServletRequest req, NoHandlerFoundException ex) {
|
public CommonResult<?> noHandlerFoundExceptionHandler(HttpServletRequest req, NoHandlerFoundException ex) {
|
||||||
// 情况一:部分功能未开启
|
|
||||||
if (req.getRequestURI().contains("/bpm/")) {
|
|
||||||
return CommonResult.error(NOT_IMPLEMENTED.getCode(), "[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 情况二:正常情况下的 404
|
|
||||||
log.warn("[noHandlerFoundExceptionHandler]", ex);
|
log.warn("[noHandlerFoundExceptionHandler]", ex);
|
||||||
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL()));
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package cn.iocoder.yudao.server.controller;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants.NOT_IMPLEMENTED;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 默认 Controller,解决部分 module 未开启时的 404 提示。
|
||||||
|
* 例如说,/bpm/** 路径,工作流
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class DefaultController {
|
||||||
|
|
||||||
|
@RequestMapping("/admin-api/bpm/**")
|
||||||
|
public CommonResult<Boolean> bpm404() {
|
||||||
|
return CommonResult.error(NOT_IMPLEMENTED.getCode(),
|
||||||
|
"[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -17,8 +17,8 @@ spring:
|
|||||||
mvc:
|
mvc:
|
||||||
pathmatch:
|
pathmatch:
|
||||||
matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类
|
matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类
|
||||||
throw-exception-if-no-handler-found: true # 404 错误时抛出异常,方便统一处理
|
# throw-exception-if-no-handler-found: true # 404 错误时抛出异常,方便统一处理
|
||||||
static-path-pattern: /static/** # 静态资源路径; 注意:如果不配置,则 throw-exception-if-no-handler-found 不生效!!!
|
# static-path-pattern: /static/** # 静态资源路径; 注意:如果不配置,则 throw-exception-if-no-handler-found 不生效!!! TODO 芋艿:不能配置,会导致 swagger 不生效
|
||||||
|
|
||||||
# Jackson 配置项
|
# Jackson 配置项
|
||||||
jackson:
|
jackson:
|
||||||
|
Loading…
Reference in New Issue
Block a user