Commit ff1379d454a936c978017f2bb454937b64d756b8
1 parent
9e393565
优化 README 说明~
Showing
4 changed files
with
23 additions
and
3 deletions
README.md
| @@ -44,6 +44,18 @@ | @@ -44,6 +44,18 @@ | ||
| 44 | | `yudao-cloud` | Spring Cloud 微服务 | **[Gitee](https://gitee.com/zhijiantianya/yudao-cloud)** [Github](https://github.com/YunaiV/yudao-cloud) | | 44 | | `yudao-cloud` | Spring Cloud 微服务 | **[Gitee](https://gitee.com/zhijiantianya/yudao-cloud)** [Github](https://github.com/YunaiV/yudao-cloud) | |
| 45 | | `Spring-Boot-Labs` | Spring Boot & Cloud 入门 | **[Gitee](https://gitee.com/zhijiantianya/SpringBoot-Labs)** [Github](https://github.com/YunaiV/SpringBoot-Labs) | | 45 | | `Spring-Boot-Labs` | Spring Boot & Cloud 入门 | **[Gitee](https://gitee.com/zhijiantianya/SpringBoot-Labs)** [Github](https://github.com/YunaiV/SpringBoot-Labs) | |
| 46 | 46 | ||
| 47 | +## 😎 开源协议 | ||
| 48 | + | ||
| 49 | +**为什么推荐使用本项目?** | ||
| 50 | + | ||
| 51 | +① 本项目采用比 Apache 2.0 更宽松的 [MIT License](https://gitee.com/zhijiantianya/ruoyi-vue-pro/blob/master/LICENSE) 开源协议,个人与企业可 100% 免费使用,不用保留类作者、Copyright 信息。 | ||
| 52 | + | ||
| 53 | +② 代码全部开源,不会像其他项目一样,只开源部分代码,让你无法了解整个项目的架构设计。[国产开源项目对比](https://www.yuque.com/xiatian-bsgny/lm0ec1/wqf8mn) | ||
| 54 | + | ||
| 55 | + | ||
| 56 | + | ||
| 57 | +③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,57000 行 Java 代码,22000 行代码注释。 | ||
| 58 | + | ||
| 47 | ## 🐼 内置功能 | 59 | ## 🐼 内置功能 |
| 48 | 60 | ||
| 49 | 系统内置多种多种业务功能,可以用于快速你的业务系统: | 61 | 系统内置多种多种业务功能,可以用于快速你的业务系统: |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/exception/enums/GlobalErrorCodeConstants.java
| @@ -29,6 +29,7 @@ public interface GlobalErrorCodeConstants { | @@ -29,6 +29,7 @@ public interface GlobalErrorCodeConstants { | ||
| 29 | // ========== 服务端错误段 ========== | 29 | // ========== 服务端错误段 ========== |
| 30 | 30 | ||
| 31 | ErrorCode INTERNAL_SERVER_ERROR = new ErrorCode(500, "系统异常"); | 31 | ErrorCode INTERNAL_SERVER_ERROR = new ErrorCode(500, "系统异常"); |
| 32 | + ErrorCode NOT_IMPLEMENTED = new ErrorCode(501, "功能未实现/未开启"); | ||
| 32 | 33 | ||
| 33 | // ========== 自定义错误段 ========== | 34 | // ========== 自定义错误段 ========== |
| 34 | ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求 | 35 | ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求,请稍后重试"); // 重复请求 |
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
| @@ -78,7 +78,7 @@ public class GlobalExceptionHandler { | @@ -78,7 +78,7 @@ public class GlobalExceptionHandler { | ||
| 78 | return validationException((ValidationException) ex); | 78 | return validationException((ValidationException) ex); |
| 79 | } | 79 | } |
| 80 | if (ex instanceof NoHandlerFoundException) { | 80 | if (ex instanceof NoHandlerFoundException) { |
| 81 | - return noHandlerFoundExceptionHandler((NoHandlerFoundException) ex); | 81 | + return noHandlerFoundExceptionHandler(request, (NoHandlerFoundException) ex); |
| 82 | } | 82 | } |
| 83 | if (ex instanceof HttpRequestMethodNotSupportedException) { | 83 | if (ex instanceof HttpRequestMethodNotSupportedException) { |
| 84 | return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex); | 84 | return httpRequestMethodNotSupportedExceptionHandler((HttpRequestMethodNotSupportedException) ex); |
| @@ -167,7 +167,13 @@ public class GlobalExceptionHandler { | @@ -167,7 +167,13 @@ public class GlobalExceptionHandler { | ||
| 167 | * 2. spring.mvc.static-path-pattern 为 /statics/** | 167 | * 2. spring.mvc.static-path-pattern 为 /statics/** |
| 168 | */ | 168 | */ |
| 169 | @ExceptionHandler(NoHandlerFoundException.class) | 169 | @ExceptionHandler(NoHandlerFoundException.class) |
| 170 | - public CommonResult<?> noHandlerFoundExceptionHandler(NoHandlerFoundException ex) { | 170 | + public CommonResult<?> noHandlerFoundExceptionHandler(HttpServletRequest req, NoHandlerFoundException ex) { |
| 171 | + // 情况一:部分功能未开启 | ||
| 172 | + if (req.getRequestURI().contains("/bpm/")) { | ||
| 173 | + return CommonResult.error(NOT_IMPLEMENTED.getCode(), "[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]"); | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + // 情况二:正常情况下的 404 | ||
| 171 | log.warn("[noHandlerFoundExceptionHandler]", ex); | 177 | log.warn("[noHandlerFoundExceptionHandler]", ex); |
| 172 | return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL())); | 178 | return CommonResult.error(NOT_FOUND.getCode(), String.format("请求地址不存在:%s", ex.getRequestURL())); |
| 173 | } | 179 | } |
yudao-server/src/main/resources/application.yaml
| @@ -17,6 +17,8 @@ spring: | @@ -17,6 +17,8 @@ spring: | ||
| 17 | mvc: | 17 | mvc: |
| 18 | pathmatch: | 18 | pathmatch: |
| 19 | matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 | 19 | matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 |
| 20 | + throw-exception-if-no-handler-found: true # 404 错误时抛出异常,方便统一处理 | ||
| 21 | + static-path-pattern: /static/** # 静态资源路径; 注意:如果不配置,则 throw-exception-if-no-handler-found 不生效!!! | ||
| 20 | 22 | ||
| 21 | # Jackson 配置项 | 23 | # Jackson 配置项 |
| 22 | jackson: | 24 | jackson: |
| @@ -25,7 +27,6 @@ spring: | @@ -25,7 +27,6 @@ spring: | ||
| 25 | write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 | 27 | write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 |
| 26 | write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 | 28 | write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 |
| 27 | fail-on-empty-beans: false # 允许序列化无属性的 Bean | 29 | fail-on-empty-beans: false # 允许序列化无属性的 Bean |
| 28 | - | ||
| 29 | # Cache 配置项 | 30 | # Cache 配置项 |
| 30 | cache: | 31 | cache: |
| 31 | type: REDIS | 32 | type: REDIS |