Browse Source

feat:更新springboot依赖

yangliu 3 months ago
parent
commit
31e7710068

+ 160 - 5
hfln-framework-design-starter/knife4j-doc-spring-boot-starter/README.md

@@ -1,10 +1,165 @@
+# Knife4j Doc Starter 使用说明
 
+基于 Knife4j 4.x + OpenAPI 3 规范的接口文档增强解决方案。
+
+## 特性
+
+- 基于 OpenAPI 3 规范
+- 支持 Spring Cloud Gateway 网关聚合文档
+- 支持 JWT 等安全认证配置
+- 支持接口分组管理
+- 支持中文界面
+
+## 快速开始
+
+### 1. 微服务中使用
+
+在需要暴露 API 文档的微服务的 `pom.xml` 中添加依赖:
+
+```xml
+<dependency>
+    <groupId>cn.hfln.framework</groupId>
+    <artifactId>knife4j-doc-spring-boot-starter</artifactId>
+    <version>${project.version}</version>
+</dependency>
 ```
-wideth:
+
+在 `application.yml` 中添加配置:
+
+```yaml
+lnxx:
   knife4j:
     doc:
-      base-package: com.example.demo.controller
-      title: 测试
-      description: 测试环境
+      enable: true
+      base-package: com.your.package  # 接口所在包路径
+      title: 服务名称
+      description: 服务描述
+      version: ${project.version}
+      enable-security: true  # 是否启用安全认证
+```
+
+### 2. Gateway 网关中使用
+
+#### 2.1 添加依赖
+
+在网关项目的 `pom.xml` 中添加依赖:
+
+```xml
+<dependency>
+    <groupId>cn.hfln.framework</groupId>
+    <artifactId>knife4j-doc-spring-boot-starter</artifactId>
+    <version>${project.version}</version>
+</dependency>
+```
+
+#### 2.2 网关配置
+
+在网关的 `application.yml` 中添加如下配置:
+
+```yaml
+spring:
+  cloud:
+    gateway:
+      routes:
+        # 文档聚合路由
+        - id: knife4j
+          uri: http://localhost:${server.port}
+          predicates:
+            - Path=/v3/api-docs/**
+          filters:
+            - RewritePath=/v3/api-docs/(?<path>.*), /$\{path}/v3/api-docs
+
+lnxx:
+  knife4j:
+    doc:
+      enable: true
+      title: API 文档中心
+      description: 微服务接口文档
+      version: ${project.version}
+      enable-security: true
+
+# 配置需要聚合的微服务文档
+springdoc:
+  swagger-ui:
+    path: /doc.html
+  api-docs:
+    enabled: true
+  group-configs:
+    - group: 'default'
+      paths-to-match: '/**'
+      packages-to-scan: cn.hfln
+```
+
+#### 2.3 创建网关聚合配置类
+
+```java
+@Configuration
+public class Knife4jGatewayConfig {
+    
+    @Bean
+    public RouterFunction<ServerResponse> apiRouter() {
+        return RouterFunctions.route()
+            .GET("/v3/api-docs/swagger-config", request ->
+                ServerResponse.ok().bodyValue(swaggerConfig()))
+            .build();
+    }
+
+    private Map<String, Object> swaggerConfig() {
+        Map<String, Object> config = new HashMap<>();
+        // 配置要聚合的微服务,key 为服务名,value 为文档地址
+        Map<String, String> services = new HashMap<>();
+        services.put("用户服务", "/user-service/v3/api-docs");
+        services.put("订单服务", "/order-service/v3/api-docs");
+        // ... 添加更多服务
+        
+        config.put("urls", services);
+        return config;
+    }
+}
+```
+
+### 3. 访问文档
+
+- 单个服务文档地址:`http://服务地址:端口/doc.html`
+- 网关聚合文档地址:`http://网关地址:端口/doc.html`
+
+## 注意事项
+
+1. 网关聚合时,确保所有微服务的 OpenAPI 文档都已启用
+2. 如果启用了安全认证,需要在 Swagger UI 界面配置对应的认证信息
+3. 建议在生产环境关闭或限制文档访问
+4. 网关层建议配置文档访问的路由限制
+
+## 常见问题
+
+1. 文档无法访问
+   - 检查服务是否正常启动
+   - 检查网关路由配置是否正确
+   - 检查安全认证配置
+
+2. 网关聚合失败
+   - 检查微服务的文档地址是否可访问
+   - 检查网关路由配置是否正确
+   - 检查网络连通性
+
+3. 认证失败
+   - 检查认证配置是否正确
+   - 确认 Token 格式是否正确
+   - 检查认证服务是否正常
+
+## 配置说明
+
+| 配置项 | 说明 | 默认值 |
+|-------|------|--------|
+| lnxx.knife4j.doc.enable | 是否启用文档 | true |
+| lnxx.knife4j.doc.base-package | 接口扫描包路径 | - |
+| lnxx.knife4j.doc.title | 文档标题 | API 文档 |
+| lnxx.knife4j.doc.description | 文档描述 | - |
+| lnxx.knife4j.doc.version | 文档版本 | 1.0.0 |
+| lnxx.knife4j.doc.enable-security | 是否启用安全认证 | false |
+
+## 版本说明
 
-```
+- 基于 Knife4j 4.x
+- 支持 Spring Boot 2.6.x 及以上版本
+- 支持 Spring Cloud 2021.x 及以上版本

+ 2 - 16
hfln-framework-design-starter/knife4j-doc-spring-boot-starter/pom.xml

@@ -16,28 +16,14 @@
         <maven.compiler.target>8</maven.compiler.target>
     </properties>
 
-
     <dependencies>
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
-            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
+            <version>${knife4j.version}</version>
         </dependency>
 
-        <dependency>
-            <groupId>com.github.xiaoymin</groupId>
-            <artifactId>knife4j-micro-spring-boot-starter</artifactId>
-        </dependency>
 
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter</artifactId>
-        </dependency>
-
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-configuration-processor</artifactId>
-            <optional>true</optional>
-        </dependency>
     </dependencies>
 
 </project>

+ 39 - 72
hfln-framework-design-starter/knife4j-doc-spring-boot-starter/src/main/java/cn/hfln/framework/knife4j/doc/base/BaseSwaggerConfig.java

@@ -1,85 +1,52 @@
 package cn.hfln.framework.knife4j.doc.base;
 
-import com.google.common.collect.Lists;
-import org.springframework.context.annotation.Bean;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.*;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
-import springfox.documentation.spring.web.plugins.Docket;
-
-import java.util.ArrayList;
-import java.util.List;
+import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.security.SecurityRequirement;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import io.swagger.v3.oas.models.servers.Server;
+import java.util.Collections;
 
 /**
  * @USER: YangLiu
- * @DESC:
+ * @DESC: 基础 Swagger 配置类,供其他模块继承和自定义
  */
 public abstract class BaseSwaggerConfig {
-    @Bean
-    public Docket createRestApi() {
-        SwaggerProperties swaggerProperties = swaggerProperties();
-        Docket docket = new Docket(DocumentationType.SWAGGER_2)
-                .apiInfo(apiInfo(swaggerProperties))
-                .select()
-                .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getApiBasePackage()))
-                .paths(PathSelectors.any())
-                .build();
-        if (swaggerProperties.isEnableSecurity()) {
-            docket.securitySchemes(Lists.newArrayList(apiKey())).securityContexts(securityContexts());
-        }
-        return docket;
-    }
-
-    private ApiInfo apiInfo(SwaggerProperties swaggerProperties) {
-        return new ApiInfoBuilder()
-                .title(swaggerProperties.getTitle())
-                .description(swaggerProperties.getDescription())
-                .contact(new Contact(swaggerProperties.getContactName(), swaggerProperties.getContactUrl(), swaggerProperties.getContactEmail()))
-                .version(swaggerProperties.getVersion())
-                .build();
-    }
-
-    private ApiKey apiKey() {
-        return new ApiKey("Authorization", "Authorization", "header");
-    }
-
-
-    private List<ApiKey> securitySchemes() {
-        //设置请求头信息
-        List<ApiKey> result = new ArrayList<>();
-        ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
-        result.add(apiKey);
-        return result;
-    }
-
-    private List<SecurityContext> securityContexts() {
-        //设置需要登录认证的路径
-        List<SecurityContext> result = new ArrayList<>();
-        result.add(getContextByPath());
-        return result;
-    }
-
-    private SecurityContext getContextByPath() {
-        return SecurityContext.builder()
-                .securityReferences(defaultAuth())
-                .forPaths(PathSelectors.regex("/*/.*"))
-                .build();
-    }
-
-    private List<SecurityReference> defaultAuth() {
-        List<SecurityReference> result = new ArrayList<>();
-        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
-        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
-        authorizationScopes[0] = authorizationScope;
-        result.add(new SecurityReference("Authorization", authorizationScopes));
-        return result;
-    }
 
     /**
      * 自定义Swagger配置
      */
     public abstract SwaggerProperties swaggerProperties();
+
+    /**
+     * 创建自定义的 OpenAPI 配置
+     */
+    protected OpenAPI createOpenAPI(SwaggerProperties swaggerProperties) {
+        OpenAPI openAPI = new OpenAPI()
+                .info(new Info()
+                        .title(swaggerProperties.getTitle())
+                        .description(swaggerProperties.getDescription())
+                        .version(swaggerProperties.getVersion())
+                        .contact(new Contact()
+                                .name(swaggerProperties.getContactName())
+                                .url(swaggerProperties.getContactUrl())
+                                .email(swaggerProperties.getContactEmail())));
+
+        if (swaggerProperties.getServerUrl() != null && !swaggerProperties.getServerUrl().isEmpty()) {
+            openAPI.setServers(Collections.singletonList(new Server().url(swaggerProperties.getServerUrl())));
+        }
+
+        if (swaggerProperties.isEnableSecurity()) {
+            openAPI.addSecurityItem(new SecurityRequirement().addList("Authorization"))
+                    .components(new Components()
+                            .addSecuritySchemes("Authorization",
+                                    new SecurityScheme()
+                                            .type(SecurityScheme.Type.HTTP)
+                                            .scheme("bearer")
+                                            .bearerFormat("JWT")));
+        }
+        return openAPI;
+    }
 }

+ 8 - 0
hfln-framework-design-starter/knife4j-doc-spring-boot-starter/src/main/java/cn/hfln/framework/knife4j/doc/base/SwaggerProperties.java

@@ -44,4 +44,12 @@ public class SwaggerProperties {
      * 文档联系人邮箱
      */
     private String contactEmail;
+    /**
+     * API 分组名称
+     */
+    private String group;
+    /**
+     * OpenAPI servers 字段,支持网关前缀
+     */
+    private String serverUrl;
 }

+ 64 - 57
hfln-framework-design-starter/knife4j-doc-spring-boot-starter/src/main/java/cn/hfln/framework/knife4j/doc/configure/DocAutoConfigure.java

@@ -1,37 +1,36 @@
 package cn.hfln.framework.knife4j.doc.configure;
 
+import cn.hfln.framework.knife4j.doc.base.BaseSwaggerConfig;
+import cn.hfln.framework.knife4j.doc.base.SwaggerProperties;
 import cn.hfln.framework.knife4j.doc.properties.DocProperties;
-import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
-import com.google.common.collect.Lists;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.License;
+import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.security.SecurityRequirement;
+import io.swagger.v3.oas.models.security.SecurityScheme;
+import io.swagger.v3.oas.models.servers.Server;
+import org.springdoc.core.SpringDocConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Import;
-import org.springframework.core.annotation.Order;
-import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
-import springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.*;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import org.springframework.context.annotation.Primary;
 
-import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @USER: YangLiu
  * knife4j 接口文档配置
  */
 @Configuration
-@EnableSwagger2
-@EnableKnife4j
-@Import(BeanValidatorPluginsConfiguration.class)
 @EnableConfigurationProperties(DocProperties.class)
 @ConditionalOnProperty(value = "lnxx.knife4j.doc.enable", havingValue = "true", matchIfMissing = true)
-public class DocAutoConfigure {
+@Import(SpringDocConfiguration.class)
+public class DocAutoConfigure extends BaseSwaggerConfig {
 
     private final DocProperties properties;
 
@@ -40,52 +39,60 @@ public class DocAutoConfigure {
     }
 
     @Bean
-    @Order(-1)
-    public Docket groupRestApi() {
-        Docket docket = new Docket(DocumentationType.SWAGGER_2)
-                .apiInfo(groupApiInfo())
-                .select()
-                .apis(RequestHandlerSelectors.basePackage(properties.getBasePackage()))
-                .paths(PathSelectors.any())
-                .build();
+    @Primary
+    @ConditionalOnMissingBean
+    public OpenAPI customOpenAPI() {
+        OpenAPI openAPI = new OpenAPI()
+                .info(new Info()
+                        .title(properties.getTitle())
+                        .description(String.format("<div style='font-size:%spx;color:%s;'>%s</div>",
+                                properties.getDescriptionFontSize(), properties.getDescriptionColor(), properties.getDescription()))
+                        .version(properties.getVersion())
+                        .contact(new Contact()
+                                .name(properties.getName())
+                                .url(properties.getUrl())
+                                .email(properties.getEmail()))
+                        .license(new License()
+                                .name(properties.getLicense())
+                                .url(properties.getLicenseUrl()))
+                        .termsOfService(properties.getTermsOfServiceUrl()));
+
+        // 只使用 yml 配置的 servers 字段,不设置默认 server
+        if (properties.getServers() != null && !properties.getServers().isEmpty()) {
+            openAPI.setServers(properties.getServers().stream()
+                    .map(cfg -> new Server().url(cfg.getUrl()).description(cfg.getDescription()))
+                    .collect(Collectors.toList()));
+        }
+
         if (properties.isEnableSecurity()) {
-            docket.securityContexts(Lists.newArrayList(securityContext()))
-                    .securitySchemes(Lists.newArrayList(apiKey()));
+            openAPI.addSecurityItem(new SecurityRequirement().addList("Bearer"))
+                    .components(new Components()
+                            .addSecuritySchemes("Bearer",
+                                    new SecurityScheme()
+                                            .type(SecurityScheme.Type.HTTP)
+                                            .scheme("bearer")
+                                            .bearerFormat("JWT")
+                                            .in(SecurityScheme.In.HEADER)
+                                            .name("Authorization")));
         }
-        return docket;
-    }
 
+        return openAPI;
+    }
 
-    private ApiInfo groupApiInfo() {
-        String description = String.format("<div style='font-size:%spx;color:%s;'>%s</div>",
-                properties.getDescriptionFontSize(), properties.getDescriptionColor(), properties.getDescription());
-        Contact contact = new Contact(properties.getName(), properties.getUrl(), properties.getEmail());
-        return new ApiInfoBuilder()
+    @Override
+    public SwaggerProperties swaggerProperties() {
+        return SwaggerProperties.builder()
+                .apiBasePackage(properties.getBasePackage())
                 .title(properties.getTitle())
-                .description(description)
-                .termsOfServiceUrl(properties.getTermsOfServiceUrl())
-                .contact(contact)
-                .license(properties.getLicense())
-                .licenseUrl(properties.getLicenseUrl())
+                .description(String.format("<div style='font-size:%spx;color:%s;'>%s</div>",
+                        properties.getDescriptionFontSize(), properties.getDescriptionColor(), properties.getDescription()))
                 .version(properties.getVersion())
+                .contactName(properties.getName())
+                .contactUrl(properties.getUrl())
+                .contactEmail(properties.getEmail())
+                .enableSecurity(properties.isEnableSecurity())
+                .group("default")
+                .serverUrl(properties.getServerUrl())
                 .build();
     }
-
-    private ApiKey apiKey() {
-        return new ApiKey("Authorization", "Authorization", "header");
-    }
-
-    private SecurityContext securityContext() {
-        return SecurityContext.builder()
-                .securityReferences(defaultAuth())
-                .forPaths(PathSelectors.regex("/.*"))
-                .build();
-    }
-
-    List<SecurityReference> defaultAuth() {
-        AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
-        AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
-        authorizationScopes[0] = authorizationScope;
-        return Lists.newArrayList(new SecurityReference("Authorization", authorizationScopes));
-    }
 }

+ 19 - 0
hfln-framework-design-starter/knife4j-doc-spring-boot-starter/src/main/java/cn/hfln/framework/knife4j/doc/properties/DocProperties.java

@@ -3,6 +3,8 @@ package cn.hfln.framework.knife4j.doc.properties;
 import lombok.Data;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
+import java.util.List;
+
 /**
  * @USER: YangLiu
  */
@@ -70,6 +72,22 @@ public class DocProperties {
      */
     private String version;
 
+    /**
+     * 网关前缀(OpenAPI servers 字段)
+     */
+    private String serverUrl;
+
+    /**
+     * OpenAPI servers 字段,支持多个
+     */
+    private List<ServerConfig> servers;
+
+    @Data
+    public static class ServerConfig {
+        private String url;
+        private String description;
+    }
+
     @Override
     public String toString() {
         return "DocProperties{" +
@@ -86,6 +104,7 @@ public class DocProperties {
                 ", license='" + license + '\'' +
                 ", licenseUrl='" + licenseUrl + '\'' +
                 ", version='" + version + '\'' +
+                ", serverUrl='" + serverUrl + '\'' +
                 '}';
     }
 }

+ 1 - 0
hfln-framework-design-starter/mqtt-spring-boot-starter/pom.xml

@@ -20,6 +20,7 @@
         <dependency>
             <groupId>org.eclipse.paho</groupId>
             <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
+            <version>1.2.5</version>
         </dependency>
 
         <!--        <dependency>-->

+ 4 - 0
hfln-framework-design-starter/mqtt-spring-boot-starter/src/main/java/cn/hfln/framework/mqtt/config/MqttAutoConfiguration.java

@@ -17,6 +17,7 @@ import org.eclipse.paho.client.mqttv3.MqttException;
 import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -43,6 +44,7 @@ import java.util.UUID;
 @Configuration
 @EnableConfigurationProperties(MqttProperties.class)
 @ConditionalOnProperty(prefix = "mqtt", name = "enabled", havingValue = "true", matchIfMissing = true)
+@ConditionalOnClass(org.eclipse.paho.client.mqttv3.MqttClient.class)
 public class MqttAutoConfiguration {
 
     private final MqttProperties mqttProperties;
@@ -60,12 +62,14 @@ public class MqttAutoConfiguration {
 
     @Bean
     @ConditionalOnMissingBean
+    @ConditionalOnClass(org.eclipse.paho.client.mqttv3.MqttClientPersistence.class)
     public MqttClientPersistence mqttClientPersistence() {
         return new MemoryPersistence();
     }
 
     @Bean
     @ConditionalOnMissingBean
+    @ConditionalOnClass(org.eclipse.paho.client.mqttv3.MqttConnectOptions.class)
     public MqttConnectOptions mqttConnectOptions() {
         MqttConnectOptions options = new MqttConnectOptions();
         options.setServerURIs(new String[]{mqttProperties.getBroker()});

+ 2 - 1
hfln-framework-design-starter/mqtt-spring-boot-starter/src/main/resources/META-INF/spring.factories

@@ -1,2 +1,3 @@
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-cn.hfln.framework.mqtt.config.MqttAutoConfiguration
+cn.hfln.framework.mqtt.config.MqttAutoConfiguration,\
+cn.hfln.framework.mqtt.config.MqttSimpleAutoConfiguration

+ 2 - 1
hfln-framework-design-starter/mqtt-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -1 +1,2 @@
-cn.hfln.framework.mqtt.config.MqttAutoConfiguration 
+cn.hfln.framework.mqtt.config.MqttAutoConfiguration
+cn.hfln.framework.mqtt.config.MqttSimpleAutoConfiguration 

+ 1 - 1
hfln-framework-dto/pom.xml

@@ -16,7 +16,7 @@
     <dependencies>
         <dependency>
             <groupId>com.github.xiaoymin</groupId>
-            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
         </dependency>
     </dependencies>
 

+ 7 - 8
hfln-framework-dto/src/main/java/cn/hfln/framework/dto/ApiResult.java

@@ -2,8 +2,7 @@ package cn.hfln.framework.dto;
 
 import cn.hfln.framework.code.IErrorCode;
 import cn.hfln.framework.code.ResultCode;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.ToString;
@@ -15,7 +14,7 @@ import java.time.LocalDateTime;
  * @DATE: 2023/10/12 2:33 下午
  * @DESC:
  */
-@ApiModel(description = "rest请求的返回模型,所有rest正常都返回该类的对象")
+@Schema(description = "rest请求的返回模型,所有rest正常都返回该类的对象")
 @Getter
 @Setter
 @ToString
@@ -24,19 +23,19 @@ public class ApiResult<T> extends DTO {
     public static final int SUCCESSFUL_CODE = 200;
     public static final String SUCCESSFUL_MES = "处理成功";
 
-    @ApiModelProperty(value = "处理结果code", required = true)
+    @Schema(description = "处理结果code", required = true)
     private String code;
 
-    @ApiModelProperty(value = "处理结果描述信息")
+    @Schema(description = "处理结果描述信息")
     private String message;
 
-    @ApiModelProperty(value = "请求结果生成时间戳")
+    @Schema(description = "请求结果生成时间戳")
     private LocalDateTime dateTime;
 
-    @ApiModelProperty(value = "处理结果数据信息")
+    @Schema(description = "处理结果数据信息")
     private T data;
 
-    @ApiModelProperty("进程Id")
+    @Schema(description = "进程Id")
     private String traceId;
 
     public ApiResult(String code, String message, T data) {

+ 3 - 3
hfln-framework-dto/src/main/java/cn/hfln/framework/dto/PageReq.java

@@ -1,6 +1,6 @@
 package cn.hfln.framework.dto;
 
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -13,10 +13,10 @@ import lombok.Setter;
 @Setter
 public class PageReq {
 
-    @ApiModelProperty(value = "分页大小,默认10")
+    @Schema(description = "分页大小,默认10")
     private Integer pageSize = 10;
 
-    @ApiModelProperty(value = "分页页码,默认1")
+    @Schema(description = "分页页码,默认1")
     private Integer pageNum = 1;
 
 }

+ 12 - 6
pom.xml

@@ -5,7 +5,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>2.3.12.RELEASE</version>
+        <version>2.6.14</version>
     </parent>
 
     <groupId>cn.hfln.framework</groupId>
@@ -34,13 +34,13 @@
         <jackson.version>2.14.0</jackson.version>
 
         <!-- SpringCloud -->
-        <spring-boot.version>2.3.12.RELEASE</spring-boot.version>
-        <spring-cloud.version>Hoxton.SR12</spring-cloud.version>
-        <spring-cloud-alibaba.version>2.2.9.RELEASE</spring-cloud-alibaba.version>
+        <spring-boot.version>2.6.14</spring-boot.version>
+        <spring-cloud.version>2021.0.8</spring-cloud.version>
+        <spring-cloud-alibaba.version>2021.1</spring-cloud-alibaba.version>
         <sentinel.version>1.8.5</sentinel.version>
         <nacos.version>2.1.0</nacos.version>
         <rocketmq.version>4.9.4</rocketmq.version>
-        <knife4j.version>3.0.3</knife4j.version>
+        <knife4j.version>4.1.0</knife4j.version>
         <mybatis-plus.version>3.5.1</mybatis-plus.version>
         <fastjson.version>2.0.41</fastjson.version>
         <transmittable.version>2.14.2</transmittable.version>
@@ -186,6 +186,12 @@
                 <artifactId>easyexcel</artifactId>
                 <version>${easy-excel.version}</version>
             </dependency>
+            <!-- Knife4j -->
+            <dependency>
+                <groupId>com.github.xiaoymin</groupId>
+                <artifactId>knife4j-openapi3-spring-boot-starter</artifactId>
+                <version>${knife4j.version}</version>
+            </dependency>
             <!-- MinIO对象存储 -->
             <dependency>
                 <groupId>io.minio</groupId>
@@ -249,7 +255,7 @@
                 <groupId>ch.qos.logback</groupId>
                 <artifactId>logback-core</artifactId>
                 <version>${logback.version}</version>
-                <scope>test</scope>
+                <scope>runtime</scope>
             </dependency>
 
             <dependency>