Commit 6fd14b30c2dd9937b9c331982662ee382b8a1787

Authored by YunaiV
1 parent b9f1eacf

1. 升级 spring boot 到 2.6.8

2. 修复 Spring Fox 在 2.6.X 版本的兼容性
README.md
... ... @@ -157,27 +157,27 @@ ps:核心功能已经实现,正在对接微信小程序中...
157 157  
158 158 | 框架 | 说明 | 版本 | 学习指南 |
159 159 |---------------------------------------------------------------------------------------------|------------------|----------|----------------------------------------------------------------|
160   -| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.5.12 | [文档](https://github.com/YunaiV/SpringBoot-Labs) |
  160 +| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.6.8 | [文档](https://github.com/YunaiV/SpringBoot-Labs) |
161 161 | [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.7 | |
162 162 | [Druid](https://github.com/alibaba/druid) | JDBC 连接池、监控组件 | 1.2.8 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) |
163 163 | [MyBatis Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.5.1 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) |
164 164 | [Dynamic Datasource](https://dynamic-datasource.com/) | 动态数据源 | 3.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) |
165 165 | [Redis](https://redis.io/) | key-value 数据库 | 5.0 | |
166   -| [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 3.16.8 | [文档](http://www.iocoder.cn/Spring-Boot/Redis/?yudao) |
167   -| [Spring MVC](https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc) | MVC 框架 | 5.3.16 | [文档](http://www.iocoder.cn/SpringMVC/MVC/?yudao) |
168   -| [Spring Security](https://github.com/spring-projects/spring-security) | Spring 安全框架 | 5.5.5 | [文档](http://www.iocoder.cn/Spring-Boot/Spring-Security/?yudao) |
169   -| [Hibernate Validator](https://github.com/hibernate/hibernate-validator) | 参数校验组件 | 6.2.2 | [文档](http://www.iocoder.cn/Spring-Boot/Validation/?yudao) |
  166 +| [Redisson](https://github.com/redisson/redisson) | Redis 客户端 | 3.17.3 | [文档](http://www.iocoder.cn/Spring-Boot/Redis/?yudao) |
  167 +| [Spring MVC](https://github.com/spring-projects/spring-framework/tree/master/spring-webmvc) | MVC 框架 | 5.3.20 | [文档](http://www.iocoder.cn/SpringMVC/MVC/?yudao) |
  168 +| [Spring Security](https://github.com/spring-projects/spring-security) | Spring 安全框架 | 5.6.5 | [文档](http://www.iocoder.cn/Spring-Boot/Spring-Security/?yudao) |
  169 +| [Hibernate Validator](https://github.com/hibernate/hibernate-validator) | 参数校验组件 | 6.2.3 | [文档](http://www.iocoder.cn/Spring-Boot/Validation/?yudao) |
170 170 | [Activiti](https://github.com/Activiti/Activiti) | 工作流引擎 | 7.1.0.M6 | [文档](TODO) |
171 171 | [Quartz](https://github.com/quartz-scheduler) | 任务调度组件 | 2.3.2 | [文档](http://www.iocoder.cn/Spring-Boot/Job/?yudao) |
172   -| [Knife4j](https://gitee.com/xiaoym/knife4j) | Swagger 增强 UI 实现 | 3.0.2 | [文档](http://www.iocoder.cn/Spring-Boot/Swagger/?yudao) |
173   -| [Resilience4j](https://github.com/resilience4j/resilience4j) | 服务保障组件 | 1.7.0 | [文档](http://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao) |
  172 +| [Knife4j](https://gitee.com/xiaoym/knife4j) | Swagger 增强 UI 实现 | 3.0.3 | [文档](http://www.iocoder.cn/Spring-Boot/Swagger/?yudao) |
  173 +| [Resilience4j](https://github.com/resilience4j/resilience4j) | 服务保障组件 | 1.7.1 | [文档](http://www.iocoder.cn/Spring-Boot/Resilience4j/?yudao) |
174 174 | [SkyWalking](https://skywalking.apache.org/) | 分布式应用追踪系统 | 8.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/SkyWalking/?yudao) |
175   -| [Spring Boot Admin](https://github.com/codecentric/spring-boot-admin) | Spring Boot 监控平台 | 2.4.2 | [文档](http://www.iocoder.cn/Spring-Boot/Admin/?yudao) |
176   -| [Jackson](https://github.com/FasterXML/jackson) | JSON 工具库 | 2.12.6 | |
  175 +| [Spring Boot Admin](https://github.com/codecentric/spring-boot-admin) | Spring Boot 监控平台 | 2.6.7 | [文档](http://www.iocoder.cn/Spring-Boot/Admin/?yudao) |
  176 +| [Jackson](https://github.com/FasterXML/jackson) | JSON 工具库 | 2.13.3 | |
177 177 | [MapStruct](https://mapstruct.org/) | Java Bean 转换 | 1.4.1 | [文档](http://www.iocoder.cn/Spring-Boot/MapStruct/?yudao) |
178 178 | [Lombok](https://projectlombok.org/) | 消除冗长的 Java 代码 | 1.16.14 | [文档](http://www.iocoder.cn/Spring-Boot/Lombok/?yudao) |
179   -| [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.7.2 | - |
180   -| [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 3.9.0 | - |
  179 +| [JUnit](https://junit.org/junit5/) | Java 单元测试框架 | 5.8.2 | - |
  180 +| [Mockito](https://github.com/mockito/mockito) | Java Mock 框架 | 4.0.0 | - |
181 181  
182 182 ### 前端
183 183  
... ...
http-client.env.json
... ... @@ -7,5 +7,14 @@
7 7 "appApi": "http://127.0.0.1:48080/app-api",
8 8 "appToken": "test1",
9 9 "appTenentId": "1"
  10 + },
  11 + "gateway": {
  12 + "baseUrl": "http://127.0.0.1:8888/admin-api",
  13 + "token": "test1",
  14 + "adminTenentId": "1",
  15 +
  16 + "appApi": "http://127.0.0.1:8888/app-api",
  17 + "appToken": "test1",
  18 + "appTenentId": "1"
10 19 }
11 20 }
... ...
yudao-dependencies/pom.xml
... ... @@ -16,31 +16,31 @@
16 16 <properties>
17 17 <revision>1.6.2-snapshot</revision>
18 18 <!-- 统一依赖管理 -->
19   - <spring.boot.version>2.5.12</spring.boot.version>
  19 + <spring.boot.version>2.6.8</spring.boot.version>
20 20 <!-- Web 相关 -->
21   - <knife4j.version>3.0.2</knife4j.version>
22   - <swagger-annotations.version>1.5.22</swagger-annotations.version>
  21 + <knife4j.version>3.0.3</knife4j.version>
  22 + <swagger-annotations.version>1.6.6</swagger-annotations.version>
23 23 <servlet.versoin>2.5</servlet.versoin>
24 24 <!-- DB 相关 -->
25 25 <druid.version>1.2.8</druid.version>
26 26 <mybatis-plus.version>3.4.3.4</mybatis-plus.version>
27 27 <mybatis-plus-generator.version>3.5.2</mybatis-plus-generator.version>
28 28 <dynamic-datasource.version>3.5.0</dynamic-datasource.version>
29   - <redisson.version>3.17.0</redisson.version>
  29 + <redisson.version>3.17.3</redisson.version>
30 30 <!-- Config 配置中心相关 -->
31 31 <apollo.version>1.9.2</apollo.version>
32 32 <!-- Job 定时任务相关 -->
33 33 <!-- 服务保障相关 -->
34 34 <lock4j.version>2.2.0</lock4j.version>
35   - <resilience4j.version>1.7.0</resilience4j.version>
  35 + <resilience4j.version>1.7.1</resilience4j.version>
36 36 <!-- 监控相关 -->
37 37 <skywalking.version>8.7.0</skywalking.version>
38   - <spring-boot-admin.version>2.6.2</spring-boot-admin.version>
  38 + <spring-boot-admin.version>2.6.7</spring-boot-admin.version>
39 39 <opentracing.version>0.31.0</opentracing.version>
40 40 <!-- Test 测试相关 -->
41 41 <podam.version>7.2.6.RELEASE</podam.version>
42 42 <jedis-mock.version>0.1.16</jedis-mock.version>
43   - <mockito-inline.version>3.9.0</mockito-inline.version>
  43 + <mockito-inline.version>4.0.0</mockito-inline.version>
44 44 <!-- Bpm 工作流相关 -->
45 45 <activiti.version>7.1.0.M6</activiti.version>
46 46 <flowable.version>6.7.0</flowable.version>
... ... @@ -52,7 +52,7 @@
52 52 <easyexcel.verion>2.2.7</easyexcel.verion>
53 53 <velocity.version>2.2</velocity.version>
54 54 <screw.version>1.0.5</screw.version>
55   - <fastjson.version>2.0.4</fastjson.version>
  55 + <fastjson.version>2.0.5</fastjson.version>
56 56 <guava.version>30.1.1-jre</guava.version>
57 57 <guice.version>5.1.0</guice.version>
58 58 <transmittable-thread-local.version>2.12.2</transmittable-thread-local.version>
... ... @@ -476,13 +476,12 @@
476 476 <version>${velocity.version}</version>
477 477 </dependency>
478 478  
479   - <!--fastjson漏洞升级此次事件影响fastjson 1.2.80及之前所有版本 -->
480 479 <dependency>
481 480 <groupId>com.alibaba</groupId>
482 481 <artifactId>fastjson</artifactId>
483 482 <version>${fastjson.version}</version>
484 483 </dependency>
485   -
  484 +
486 485 <dependency>
487 486 <groupId>cn.smallbun.screw</groupId>
488 487 <artifactId>screw-core</artifactId> <!-- 实现数据库文档 -->
... ...
yudao-framework/yudao-spring-boot-starter-biz-data-permission/src/test/java/cn/iocoder/yudao/framework/datapermission/core/db/DataPermissionDatabaseInterceptorTest.java
... ... @@ -62,7 +62,7 @@ public class DataPermissionDatabaseInterceptorTest extends BaseMockitoUnitTest {
62 62 // 调用
63 63 interceptor.beforeQuery(null, mappedStatement, null, null, null, boundSql);
64 64 // 断言
65   - pluginUtilsMock.verify(never(), () -> PluginUtils.mpBoundSql(boundSql));
  65 + pluginUtilsMock.verify(() -> PluginUtils.mpBoundSql(boundSql), never());
66 66 }
67 67 }
68 68  
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/config/YudaoSwaggerAutoConfiguration.java
1 1 package cn.iocoder.yudao.framework.swagger.config;
2 2  
  3 +import cn.iocoder.yudao.framework.swagger.core.SpringFoxHandlerProviderBeanPostProcessor;
3 4 import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
4 5 import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
5 6 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
... ... @@ -21,8 +22,6 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
21 22 import java.util.Collections;
22 23 import java.util.List;
23 24  
24   -import static springfox.documentation.builders.RequestHandlerSelectors.basePackage;
25   -
26 25 /**
27 26 * Swagger2 自动配置类
28 27 *
... ... @@ -38,6 +37,11 @@ import static springfox.documentation.builders.RequestHandlerSelectors.basePacka
38 37 public class YudaoSwaggerAutoConfiguration {
39 38  
40 39 @Bean
  40 + public SpringFoxHandlerProviderBeanPostProcessor springFoxHandlerProviderBeanPostProcessor() {
  41 + return new SpringFoxHandlerProviderBeanPostProcessor();
  42 + }
  43 +
  44 + @Bean
41 45 @ConditionalOnMissingBean
42 46 public SwaggerProperties swaggerProperties() {
43 47 return new SwaggerProperties();
... ... @@ -52,8 +56,8 @@ public class YudaoSwaggerAutoConfiguration {
52 56 .apiInfo(apiInfo(properties))
53 57 // 设置扫描指定 package 包下的
54 58 .select()
55   - .apis(basePackage(properties.getBasePackage()))
56   -// .apis(basePackage("cn.iocoder.yudao.module.infra")) // 可用于 swagger 无法展示时使用
  59 +// .apis(basePackage(properties.getBasePackage()))
  60 +// .apis(basePackage("cn.iocoder.yudao.module.system")) // 可用于 swagger 无法展示时使用
57 61 .paths(PathSelectors.any())
58 62 .build()
59 63 .securitySchemes(securitySchemes())
... ...
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/swagger/core/SpringFoxHandlerProviderBeanPostProcessor.java 0 → 100644
  1 +package cn.iocoder.yudao.framework.swagger.core;
  2 +
  3 +import cn.hutool.core.util.ReflectUtil;
  4 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  5 +import org.springframework.beans.BeansException;
  6 +import org.springframework.beans.factory.config.BeanPostProcessor;
  7 +import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
  8 +import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
  9 +import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题
  15 + * 该问题对应的 issue 为 https://github.com/springfox/springfox/issues/3462
  16 + *
  17 + * @author 芋道源码
  18 + */
  19 +public class SpringFoxHandlerProviderBeanPostProcessor implements BeanPostProcessor {
  20 +
  21 + @Override
  22 + public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
  23 + if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
  24 + customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
  25 + }
  26 + return bean;
  27 + }
  28 +
  29 + private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
  30 + // 移除,只保留 patternParser
  31 + List<T> copy = CollectionUtils.filterList(mappings, mapping -> mapping.getPatternParser() == null);
  32 + // 添加到 mappings 中
  33 + mappings.clear();
  34 + mappings.addAll(copy);
  35 + }
  36 +
  37 + @SuppressWarnings("unchecked")
  38 + private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
  39 + return (List<RequestMappingInfoHandlerMapping>)
  40 + ReflectUtil.getFieldValue(bean, "handlerMappings");
  41 + }
  42 +
  43 +}
... ...
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/controller/admin/oauth2/OAuth2OpenControllerTest.java
... ... @@ -77,7 +77,7 @@ public class OAuth2OpenControllerTest extends BaseMockitoUnitTest {
77 77  
78 78 // mock 方法(访问令牌)
79 79 OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class)
80   - .setExpiresTime(addTime(Duration.ofMillis(30010L))); // 多给 10 毫秒,保证可执行完
  80 + .setExpiresTime(addTime(Duration.ofMillis(30050L))); // 多给 10 毫秒,保证可执行完
81 81 when(oauth2GrantService.grantAuthorizationCodeForAccessToken(eq("test_client_id"),
82 82 eq(code), eq(redirectUri), eq(state))).thenReturn(accessTokenDO);
83 83  
... ... @@ -105,7 +105,7 @@ public class OAuth2OpenControllerTest extends BaseMockitoUnitTest {
105 105  
106 106 // mock 方法(访问令牌)
107 107 OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class)
108   - .setExpiresTime(addTime(Duration.ofMillis(30010L))); // 多给 10 毫秒,保证可执行完
  108 + .setExpiresTime(addTime(Duration.ofMillis(30050L))); // 多给 10 毫秒,保证可执行完
109 109 when(oauth2GrantService.grantPassword(eq(username), eq(password), eq("test_client_id"),
110 110 eq(Lists.newArrayList("write", "read")))).thenReturn(accessTokenDO);
111 111  
... ...
yudao-server/pom.xml
... ... @@ -76,7 +76,7 @@
76 76 <plugin>
77 77 <groupId>org.springframework.boot</groupId>
78 78 <artifactId>spring-boot-maven-plugin</artifactId>
79   - <version>2.5.12</version> <!-- 如果 spring.boot.version 版本修改,则这里也要跟着修改 -->
  79 + <version>2.6.7</version> <!-- 如果 spring.boot.version 版本修改,则这里也要跟着修改 -->
80 80 <configuration>
81 81 <fork>true</fork>
82 82 </configuration>
... ...
yudao-server/src/main/resources/application.yaml
... ... @@ -5,12 +5,18 @@ spring:
5 5 profiles:
6 6 active: local
7 7  
  8 + main:
  9 + allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
  10 +
8 11 # Servlet 配置
9 12 servlet:
10 13 # 文件上传相关配置项
11 14 multipart:
12 15 max-file-size: 16MB # 单个文件大小
13 16 max-request-size: 32MB # 设置总上传的文件大小
  17 + mvc:
  18 + pathmatch:
  19 + matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类
14 20  
15 21 # Jackson 配置项
16 22 jackson:
... ...