diff --git a/jeecg-boot/jeecg-boot-base-core/pom.xml b/jeecg-boot/jeecg-boot-base-core/pom.xml
index c667353c8..d6f8b9bf0 100644
--- a/jeecg-boot/jeecg-boot-base-core/pom.xml
+++ b/jeecg-boot/jeecg-boot-base-core/pom.xml
@@ -264,12 +264,12 @@
-
- com.github.xingfudeshi
+
+
com.github.xiaoymin
knife4j-openapi3-ui
@@ -279,7 +279,7 @@
org.springdoc
springdoc-openapi-starter-webmvc-ui
2.7.0
- -->
+
diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java
index 1878b5827..0700b463a 100644
--- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java
+++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/Swagger3Config.java
@@ -10,11 +10,12 @@ import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.constant.CommonConstant;
-import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
+import org.springdoc.core.customizers.OperationCustomizer;
import org.springdoc.core.filters.GlobalOpenApiMethodFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
+import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -61,29 +62,17 @@ public class Swagger3Config implements WebMvcConfigurer {
}
@Bean
- public GlobalOpenApiCustomizer globalOpenApiCustomizer() {
- return openApi -> {
- // 全局添加鉴权参数
- if (openApi.getPaths() != null) {
- openApi.getPaths().forEach((path, pathItem) -> {
- //log.info("path: {}", path);
- // 检查当前路径是否在排除列表中
- boolean isExcluded = excludedPaths.stream().anyMatch(
- excludedPath -> excludedPath.equals(path) || (excludedPath.endsWith("**") && path.startsWith(excludedPath.substring(0, excludedPath.length() - 2)))
- );
-
- if (!isExcluded) {
- //log.info(" 接口添加默认X_ACCESS_TOKEN: {}", path);
- // 接口添加鉴权参数
- pathItem.readOperations().forEach(operation ->
- operation.addSecurityItem(new SecurityRequirement().addList(CommonConstant.X_ACCESS_TOKEN))
- );
- }
- });
+ public OperationCustomizer operationCustomizer() {
+ return (operation, handlerMethod) -> {
+ String path = handlerMethod.getBeanType().getAnnotation(RequestMapping.class).value()[0];
+ if (!excludedPaths.contains(path)) {
+ operation.addSecurityItem(new SecurityRequirement().addList(CommonConstant.X_ACCESS_TOKEN));
}
+ return operation;
};
}
-
+
+
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
diff --git a/jeecg-boot/pom.xml b/jeecg-boot/pom.xml
index 92029babc..f466c651d 100644
--- a/jeecg-boot/pom.xml
+++ b/jeecg-boot/pom.xml
@@ -43,7 +43,7 @@
5.2.6
1.6.0
0.17.0
- 4.6.0
+ 4.5.0
42.2.25
11.2.0.3