diff --git a/docker/copy.sh b/docker/copy.sh
index 23d61874d..9a5d2ae65 100644
--- a/docker/copy.sh
+++ b/docker/copy.sh
@@ -9,8 +9,8 @@ usage() {
# copy sql
echo "begin copy sql "
-cp ../sql/ry_20231130.sql ./mysql/db
-cp ../sql/ry_config_20231204.sql ./mysql/db
+cp ../sql/ry_20240629.sql ./mysql/db
+cp ../sql/ry_config_20240829.sql ./mysql/db
# copy html
echo "begin copy html "
diff --git a/pom.xml b/pom.xml
index 509b51212..4261c9d25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,25 +16,25 @@
3.6.4
UTF-8
UTF-8
- 1.8
- 2.7.18
- 2021.0.8
- 2021.0.5.0
- 5.3.33
- 2.7.15
+ 17
+ 3.3.3
+ 2023.0.3
+ 2023.0.1.2
+ 3.3.3
+ 3.0.3
3.0.0
1.6.2
- 1.27.2
2.3.3
- 2.0.0
+ 2.1.0
1.2.23
- 4.2.0
+ 4.3.1
2.13.0
2.3
2.0.43
0.9.1
8.2.2
4.1.2
+ 2.5.0
2.14.4
@@ -42,15 +42,6 @@
-
-
- org.springframework
- spring-framework-bom
- ${spring-framework.version}
- pom
- import
-
-
org.springframework.cloud
@@ -78,23 +69,11 @@
import
-
+
- com.github.tobato
- fastdfs-client
- ${tobato.version}
-
-
-
-
- io.swagger
- swagger-models
- ${swagger.core.version}
-
-
- io.swagger
- swagger-annotations
- ${swagger.core.version}
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ ${springdoc.version}
@@ -109,6 +88,18 @@
com.github.pagehelper
pagehelper-spring-boot-starter
${pagehelper.boot.version}
+
+
+ mybatis-spring
+ org.mybatis
+
+
+
+
+
+ org.mybatis
+ mybatis-spring
+ ${mybatis-spring.version}
@@ -249,7 +240,9 @@
org.apache.maven.plugins
maven-compiler-plugin
+ 3.11.0
+ true
${java.version}
${project.build.sourceEncoding}
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java
index 0290a0afd..043dfefcf 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDept.java
@@ -2,10 +2,10 @@ package com.ruoyi.system.api.domain;
import java.util.ArrayList;
import java.util.List;
-import javax.validation.constraints.Email;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
+import jakarta.validation.constraints.Email;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.web.domain.BaseEntity;
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictData.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictData.java
index 014a6915b..1f88597aa 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictData.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictData.java
@@ -1,7 +1,7 @@
package com.ruoyi.system.api.domain;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.Size;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictType.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictType.java
index 4a558745f..94d90c3f9 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictType.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysDictType.java
@@ -1,8 +1,8 @@
package com.ruoyi.system.api.domain;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.Pattern;
-import javax.validation.constraints.Size;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.Pattern;
+import jakarta.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java
index f224b4222..34d099075 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysRole.java
@@ -1,9 +1,9 @@
package com.ruoyi.system.api.domain;
import java.util.Set;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
diff --git a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java
index e0c38d01c..1b266dffd 100644
--- a/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java
+++ b/ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/SysUser.java
@@ -2,7 +2,7 @@ package com.ruoyi.system.api.domain;
import java.util.Date;
import java.util.List;
-import javax.validation.constraints.*;
+import jakarta.validation.constraints.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
diff --git a/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
index 3b93514ed..c21dee562 100644
--- a/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
+++ b/ruoyi-auth/src/main/java/com/ruoyi/auth/controller/TokenController.java
@@ -1,6 +1,6 @@
package com.ruoyi.auth.controller;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
diff --git a/ruoyi-common/ruoyi-common-core/pom.xml b/ruoyi-common/ruoyi-common-core/pom.xml
index 149a4cf3d..7770cd7f0 100644
--- a/ruoyi-common/ruoyi-common-core/pom.xml
+++ b/ruoyi-common/ruoyi-common-core/pom.xml
@@ -53,12 +53,24 @@
pagehelper-spring-boot-starter
+
+
+ org.mybatis
+ mybatis-spring
+
+
org.springframework.boot
spring-boot-starter-validation
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
com.fasterxml.jackson.core
@@ -81,6 +93,7 @@
javax.xml.bind
jaxb-api
+ 2.3.1
@@ -103,14 +116,8 @@
- javax.servlet
- javax.servlet-api
-
-
-
-
- io.swagger
- swagger-annotations
+ jakarta.servlet
+ jakarta.servlet-api
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java
index cda371695..377d46587 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ServletUtils.java
@@ -8,10 +8,10 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpSession;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/bean/BeanValidators.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/bean/BeanValidators.java
index 758772620..3e94f8432 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/bean/BeanValidators.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/bean/BeanValidators.java
@@ -1,9 +1,9 @@
package com.ruoyi.common.core.utils.bean;
import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.ConstraintViolationException;
-import javax.validation.Validator;
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.ConstraintViolationException;
+import jakarta.validation.Validator;
/**
* bean对象属性验证
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/FileUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/FileUtils.java
index 0c28db794..8904c9553 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/FileUtils.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/file/FileUtils.java
@@ -8,8 +8,8 @@ import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import com.ruoyi.common.core.utils.StringUtils;
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ip/IpUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ip/IpUtils.java
index 43366ec71..878ed91c1 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ip/IpUtils.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ip/IpUtils.java
@@ -2,7 +2,7 @@ package com.ruoyi.common.core.utils.ip;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import com.ruoyi.common.core.utils.ServletUtils;
import com.ruoyi.common.core.utils.StringUtils;
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java
index f182fd38f..50f6be4be 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java
@@ -19,7 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RegExUtils;
import org.apache.commons.lang3.reflect.FieldUtils;
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/Xss.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/Xss.java
index 0a94d6b4b..081a5a7eb 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/Xss.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/Xss.java
@@ -1,7 +1,7 @@
package com.ruoyi.common.core.xss;
-import javax.validation.Constraint;
-import javax.validation.Payload;
+import jakarta.validation.Constraint;
+import jakarta.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java
index 0acf38697..b64c20933 100644
--- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java
+++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java
@@ -2,8 +2,8 @@ package com.ruoyi.common.core.xss;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
+import jakarta.validation.ConstraintValidator;
+import jakarta.validation.ConstraintValidatorContext;
import com.ruoyi.common.core.utils.StringUtils;
/**
diff --git a/ruoyi-common/ruoyi-common-datasource/pom.xml b/ruoyi-common/ruoyi-common-datasource/pom.xml
index 56e46ff19..bc643c14a 100644
--- a/ruoyi-common/ruoyi-common-datasource/pom.xml
+++ b/ruoyi-common/ruoyi-common-datasource/pom.xml
@@ -20,14 +20,14 @@
com.alibaba
- druid-spring-boot-starter
+ druid-spring-boot-3-starter
${druid.version}
com.baomidou
- dynamic-datasource-spring-boot-starter
+ dynamic-datasource-spring-boot3-starter
${dynamic-ds.version}
diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
index b453238fe..1c815c89b 100644
--- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
+++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
@@ -2,8 +2,8 @@ package com.ruoyi.common.log.aspect;
import java.util.Collection;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
diff --git a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java
index 7363c8a42..ec2339763 100644
--- a/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java
+++ b/ruoyi-common/ruoyi-common-redis/src/main/java/com/ruoyi/common/redis/configure/RedisConfig.java
@@ -18,6 +18,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
@EnableCaching
@AutoConfigureBefore(RedisAutoConfiguration.class)
+@SuppressWarnings("deprecation")
public class RedisConfig extends CachingConfigurerSupport
{
@Bean
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java
index 1cdf62392..100461451 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java
@@ -1,7 +1,7 @@
package com.ruoyi.common.security.feign;
import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Component;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.utils.ServletUtils;
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java
index 476638c4d..13363d087 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/handler/GlobalExceptionHandler.java
@@ -1,6 +1,6 @@
package com.ruoyi.common.security.handler;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindException;
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java
index 3453e1d19..2dcc71534 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/interceptor/HeaderInterceptor.java
@@ -1,7 +1,7 @@
package com.ruoyi.common.security.interceptor;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
import com.ruoyi.common.core.constant.SecurityConstants;
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
index 29717928b..ab1553496 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
@@ -3,7 +3,7 @@ package com.ruoyi.common.security.service;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
index 78a53932d..741d5b0e8 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
@@ -1,6 +1,6 @@
package com.ruoyi.common.security.utils;
-import javax.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletRequest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.TokenConstants;
diff --git a/ruoyi-common/ruoyi-common-swagger/pom.xml b/ruoyi-common/ruoyi-common-swagger/pom.xml
index a31d0975e..af46c1ede 100644
--- a/ruoyi-common/ruoyi-common-swagger/pom.xml
+++ b/ruoyi-common/ruoyi-common-swagger/pom.xml
@@ -23,11 +23,10 @@
spring-boot-starter-web
-
+
- io.springfox
- springfox-swagger2
- ${swagger.fox.version}
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/annotation/EnableCustomSwagger2.java b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/annotation/EnableCustomSwagger2.java
deleted file mode 100644
index 6832fe1b4..000000000
--- a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/annotation/EnableCustomSwagger2.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.ruoyi.common.swagger.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.springframework.context.annotation.Import;
-import com.ruoyi.common.swagger.config.SwaggerAutoConfiguration;
-
-@Target({ ElementType.TYPE })
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-@Inherited
-@Import({ SwaggerAutoConfiguration.class })
-public @interface EnableCustomSwagger2
-{
-
-}
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SpringDocAutoConfiguration.java b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SpringDocAutoConfiguration.java
new file mode 100644
index 000000000..57419d4c6
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SpringDocAutoConfiguration.java
@@ -0,0 +1,66 @@
+package com.ruoyi.common.swagger.config;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.springdoc.core.configuration.SpringDocConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+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 com.ruoyi.common.swagger.config.properties.SpringDocProperties;
+import io.swagger.v3.oas.models.Components;
+import io.swagger.v3.oas.models.OpenAPI;
+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;
+
+/**
+ * Swagger 文档配置
+ *
+ * @author ruoyi
+ */
+@AutoConfiguration(before = SpringDocConfiguration.class)
+@EnableConfigurationProperties(SpringDocProperties.class)
+@ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true)
+public class SpringDocAutoConfiguration
+{
+ @Bean
+ @ConditionalOnMissingBean(OpenAPI.class)
+ public OpenAPI openApi(SpringDocProperties properties)
+ {
+ return new OpenAPI().components(new Components()
+ // 设置认证的请求头
+ .addSecuritySchemes("apikey", securityScheme()))
+ .addSecurityItem(new SecurityRequirement().addList("apikey"))
+ .info(convertInfo(properties.getInfo()))
+ .servers(servers(properties.getGatewayUrl()));
+ }
+
+ public SecurityScheme securityScheme()
+ {
+ return new SecurityScheme().type(SecurityScheme.Type.APIKEY)
+ .name("Authorization")
+ .in(SecurityScheme.In.HEADER)
+ .scheme("Bearer");
+ }
+
+ private Info convertInfo(SpringDocProperties.InfoProperties infoProperties)
+ {
+ Info info = new Info();
+ info.setTitle(infoProperties.getTitle());
+ info.setDescription(infoProperties.getDescription());
+ info.setContact(infoProperties.getContact());
+ info.setLicense(infoProperties.getLicense());
+ info.setVersion(infoProperties.getVersion());
+ return info;
+ }
+
+ public List servers(String gatewayUrl)
+ {
+ List serverList = new ArrayList<>();
+ serverList.add(new Server().url(gatewayUrl));
+ return serverList;
+ }
+}
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerAutoConfiguration.java b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerAutoConfiguration.java
deleted file mode 100644
index 22dfeeb13..000000000
--- a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerAutoConfiguration.java
+++ /dev/null
@@ -1,123 +0,0 @@
-package com.ruoyi.common.swagger.config;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.function.Predicate;
-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 springfox.documentation.builders.ApiInfoBuilder;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.ApiKey;
-import springfox.documentation.service.AuthorizationScope;
-import springfox.documentation.service.Contact;
-import springfox.documentation.service.SecurityReference;
-import springfox.documentation.service.SecurityScheme;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spi.service.contexts.SecurityContext;
-import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-@Configuration
-@EnableSwagger2
-@EnableConfigurationProperties(SwaggerProperties.class)
-@ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true)
-@Import({SwaggerBeanPostProcessor.class, SwaggerWebConfiguration.class})
-public class SwaggerAutoConfiguration
-{
- /**
- * 默认的排除路径,排除Spring Boot默认的错误处理路径和端点
- */
- private static final List DEFAULT_EXCLUDE_PATH = Arrays.asList("/error", "/actuator/**");
-
- private static final String BASE_PATH = "/**";
-
- @Bean
- public Docket api(SwaggerProperties swaggerProperties)
- {
- // base-path处理
- if (swaggerProperties.getBasePath().isEmpty())
- {
- swaggerProperties.getBasePath().add(BASE_PATH);
- }
- // noinspection unchecked
- List> basePath = new ArrayList>();
- swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path)));
-
- // exclude-path处理
- if (swaggerProperties.getExcludePath().isEmpty())
- {
- swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH);
- }
-
- List> excludePath = new ArrayList<>();
- swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path)));
-
- ApiSelectorBuilder builder = new Docket(DocumentationType.SWAGGER_2).host(swaggerProperties.getHost())
- .apiInfo(apiInfo(swaggerProperties)).select()
- .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage()));
-
- swaggerProperties.getBasePath().forEach(p -> builder.paths(PathSelectors.ant(p)));
- swaggerProperties.getExcludePath().forEach(p -> builder.paths(PathSelectors.ant(p).negate()));
-
- return builder.build().securitySchemes(securitySchemes()).securityContexts(securityContexts()).pathMapping("/");
- }
-
- /**
- * 安全模式,这里指定token通过Authorization头请求头传递
- */
- private List securitySchemes()
- {
- List apiKeyList = new ArrayList();
- apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
- return apiKeyList;
- }
-
- /**
- * 安全上下文
- */
- private List securityContexts()
- {
- List securityContexts = new ArrayList<>();
- securityContexts.add(
- SecurityContext.builder()
- .securityReferences(defaultAuth())
- .operationSelector(o -> o.requestMappingPattern().matches("/.*"))
- .build());
- return securityContexts;
- }
-
- /**
- * 默认的全局鉴权策略
- *
- * @return
- */
- private List defaultAuth()
- {
- AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
- AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
- authorizationScopes[0] = authorizationScope;
- List securityReferences = new ArrayList<>();
- securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
- return securityReferences;
- }
-
- private ApiInfo apiInfo(SwaggerProperties swaggerProperties)
- {
- return new ApiInfoBuilder()
- .title(swaggerProperties.getTitle())
- .description(swaggerProperties.getDescription())
- .license(swaggerProperties.getLicense())
- .licenseUrl(swaggerProperties.getLicenseUrl())
- .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl())
- .contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail()))
- .version(swaggerProperties.getVersion())
- .build();
- }
-}
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerBeanPostProcessor.java b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerBeanPostProcessor.java
deleted file mode 100644
index 3837f7151..000000000
--- a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerBeanPostProcessor.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.ruoyi.common.swagger.config;
-
-import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.config.BeanPostProcessor;
-import org.springframework.util.ReflectionUtils;
-import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
-import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
-import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * swagger 在 springboot 2.6.x 不兼容问题的处理
- *
- * @author ruoyi
- */
-public class SwaggerBeanPostProcessor implements BeanPostProcessor
-{
- @Override
- public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
- {
- if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider)
- {
- customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
- }
- return bean;
- }
-
- private void customizeSpringfoxHandlerMappings(List mappings)
- {
- List copy = mappings.stream().filter(mapping -> mapping.getPatternParser() == null)
- .collect(Collectors.toList());
- mappings.clear();
- mappings.addAll(copy);
- }
-
- @SuppressWarnings("unchecked")
- private List getHandlerMappings(Object bean)
- {
- try
- {
- Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
- field.setAccessible(true);
- return (List) field.get(bean);
- }
- catch (IllegalArgumentException | IllegalAccessException e)
- {
- throw new IllegalStateException(e);
- }
- }
-}
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerProperties.java b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerProperties.java
deleted file mode 100644
index d8d5c846b..000000000
--- a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerProperties.java
+++ /dev/null
@@ -1,343 +0,0 @@
-package com.ruoyi.common.swagger.config;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-@ConfigurationProperties("swagger")
-public class SwaggerProperties
-{
- /**
- * 是否开启swagger
- */
- private Boolean enabled;
-
- /**
- * swagger会解析的包路径
- **/
- private String basePackage = "";
-
- /**
- * swagger会解析的url规则
- **/
- private List basePath = new ArrayList<>();
-
- /**
- * 在basePath基础上需要排除的url规则
- **/
- private List excludePath = new ArrayList<>();
-
- /**
- * 标题
- **/
- private String title = "";
-
- /**
- * 描述
- **/
- private String description = "";
-
- /**
- * 版本
- **/
- private String version = "";
-
- /**
- * 许可证
- **/
- private String license = "";
-
- /**
- * 许可证URL
- **/
- private String licenseUrl = "";
-
- /**
- * 服务条款URL
- **/
- private String termsOfServiceUrl = "";
-
- /**
- * host信息
- **/
- private String host = "";
-
- /**
- * 联系人信息
- */
- private Contact contact = new Contact();
-
- /**
- * 全局统一鉴权配置
- **/
- private Authorization authorization = new Authorization();
-
- public Boolean getEnabled()
- {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled)
- {
- this.enabled = enabled;
- }
-
- public String getBasePackage()
- {
- return basePackage;
- }
-
- public void setBasePackage(String basePackage)
- {
- this.basePackage = basePackage;
- }
-
- public List getBasePath()
- {
- return basePath;
- }
-
- public void setBasePath(List basePath)
- {
- this.basePath = basePath;
- }
-
- public List getExcludePath()
- {
- return excludePath;
- }
-
- public void setExcludePath(List excludePath)
- {
- this.excludePath = excludePath;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public void setTitle(String title)
- {
- this.title = title;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription(String description)
- {
- this.description = description;
- }
-
- public String getVersion()
- {
- return version;
- }
-
- public void setVersion(String version)
- {
- this.version = version;
- }
-
- public String getLicense()
- {
- return license;
- }
-
- public void setLicense(String license)
- {
- this.license = license;
- }
-
- public String getLicenseUrl()
- {
- return licenseUrl;
- }
-
- public void setLicenseUrl(String licenseUrl)
- {
- this.licenseUrl = licenseUrl;
- }
-
- public String getTermsOfServiceUrl()
- {
- return termsOfServiceUrl;
- }
-
- public void setTermsOfServiceUrl(String termsOfServiceUrl)
- {
- this.termsOfServiceUrl = termsOfServiceUrl;
- }
-
- public String getHost()
- {
- return host;
- }
-
- public void setHost(String host)
- {
- this.host = host;
- }
-
- public Contact getContact()
- {
- return contact;
- }
-
- public void setContact(Contact contact)
- {
- this.contact = contact;
- }
-
- public Authorization getAuthorization()
- {
- return authorization;
- }
-
- public void setAuthorization(Authorization authorization)
- {
- this.authorization = authorization;
- }
-
- public static class Contact
- {
- /**
- * 联系人
- **/
- private String name = "";
- /**
- * 联系人url
- **/
- private String url = "";
- /**
- * 联系人email
- **/
- private String email = "";
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getUrl()
- {
- return url;
- }
-
- public void setUrl(String url)
- {
- this.url = url;
- }
-
- public String getEmail()
- {
- return email;
- }
-
- public void setEmail(String email)
- {
- this.email = email;
- }
- }
-
- public static class Authorization
- {
- /**
- * 鉴权策略ID,需要和SecurityReferences ID保持一致
- */
- private String name = "";
-
- /**
- * 需要开启鉴权URL的正则
- */
- private String authRegex = "^.*$";
-
- /**
- * 鉴权作用域列表
- */
- private List authorizationScopeList = new ArrayList<>();
-
- private List tokenUrlList = new ArrayList<>();
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- public String getAuthRegex()
- {
- return authRegex;
- }
-
- public void setAuthRegex(String authRegex)
- {
- this.authRegex = authRegex;
- }
-
- public List getAuthorizationScopeList()
- {
- return authorizationScopeList;
- }
-
- public void setAuthorizationScopeList(List authorizationScopeList)
- {
- this.authorizationScopeList = authorizationScopeList;
- }
-
- public List getTokenUrlList()
- {
- return tokenUrlList;
- }
-
- public void setTokenUrlList(List tokenUrlList)
- {
- this.tokenUrlList = tokenUrlList;
- }
- }
-
- public static class AuthorizationScope
- {
- /**
- * 作用域名称
- */
- private String scope = "";
-
- /**
- * 作用域描述
- */
- private String description = "";
-
- public String getScope()
- {
- return scope;
- }
-
- public void setScope(String scope)
- {
- this.scope = scope;
- }
-
- public String getDescription()
- {
- return description;
- }
-
- public void setDescription(String description)
- {
- this.description = description;
- }
- }
-}
\ No newline at end of file
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerWebConfiguration.java b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerWebConfiguration.java
deleted file mode 100644
index 28556b5e8..000000000
--- a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/SwaggerWebConfiguration.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.ruoyi.common.swagger.config;
-
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-/**
- * swagger 资源映射路径
- *
- * @author ruoyi
- */
-public class SwaggerWebConfiguration implements WebMvcConfigurer
-{
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry)
- {
- /** swagger-ui 地址 */
- registry.addResourceHandler("/swagger-ui/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
- }
-}
\ No newline at end of file
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/properties/SpringDocProperties.java b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/properties/SpringDocProperties.java
new file mode 100644
index 000000000..fb892c255
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-swagger/src/main/java/com/ruoyi/common/swagger/config/properties/SpringDocProperties.java
@@ -0,0 +1,135 @@
+package com.ruoyi.common.swagger.config.properties;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
+import io.swagger.v3.oas.models.info.Contact;
+import io.swagger.v3.oas.models.info.License;
+
+/**
+ * Swagger 配置属性
+ *
+ * @author ruoyi
+ */
+@ConfigurationProperties(prefix = "springdoc")
+public class SpringDocProperties
+{
+ /**
+ * 网关
+ */
+ private String gatewayUrl;
+
+ /**
+ * 文档基本信息
+ */
+ @NestedConfigurationProperty
+ private InfoProperties info = new InfoProperties();
+
+ /**
+ *
+ * 文档的基础属性信息
+ *
+ *
+ * @see io.swagger.v3.oas.models.info.Info
+ *
+ * 为了 springboot 自动生产配置提示信息,所以这里复制一个类出来
+ */
+ public static class InfoProperties
+ {
+ /**
+ * 标题
+ */
+ private String title = null;
+
+ /**
+ * 描述
+ */
+ private String description = null;
+
+ /**
+ * 联系人信息
+ */
+ @NestedConfigurationProperty
+ private Contact contact = null;
+
+ /**
+ * 许可证
+ */
+ @NestedConfigurationProperty
+ private License license = null;
+
+ /**
+ * 版本
+ */
+ private String version = null;
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public Contact getContact()
+ {
+ return contact;
+ }
+
+ public void setContact(Contact contact)
+ {
+ this.contact = contact;
+ }
+
+ public License getLicense()
+ {
+ return license;
+ }
+
+ public void setLicense(License license)
+ {
+ this.license = license;
+ }
+
+ public String getVersion()
+ {
+ return version;
+ }
+
+ public void setVersion(String version)
+ {
+ this.version = version;
+ }
+ }
+
+ public String getGatewayUrl()
+ {
+ return gatewayUrl;
+ }
+
+ public void setGatewayUrl(String gatewayUrl)
+ {
+ this.gatewayUrl = gatewayUrl;
+ }
+
+ public InfoProperties getInfo()
+ {
+ return info;
+ }
+
+ public void setInfo(InfoProperties info)
+ {
+ this.info = info;
+ }
+}
diff --git a/ruoyi-common/ruoyi-common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-common/ruoyi-common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index f366a1613..88a7ca4ee 100644
--- a/ruoyi-common/ruoyi-common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/ruoyi-common/ruoyi-common-swagger/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1,3 +1 @@
-# com.ruoyi.common.swagger.config.SwaggerAutoConfiguration
-# com.ruoyi.common.swagger.config.SwaggerWebConfiguration
-# com.ruoyi.common.swagger.config.SwaggerBeanPostProcessor
+com.ruoyi.common.swagger.config.SpringDocAutoConfiguration
\ No newline at end of file
diff --git a/ruoyi-gateway/pom.xml b/ruoyi-gateway/pom.xml
index 771df7fd0..ed9894365 100644
--- a/ruoyi-gateway/pom.xml
+++ b/ruoyi-gateway/pom.xml
@@ -76,16 +76,11 @@
ruoyi-common-redis
-
+
- io.springfox
- springfox-swagger-ui
- ${swagger.fox.version}
-
-
- io.springfox
- springfox-swagger2
- ${swagger.fox.version}
+ org.springdoc
+ springdoc-openapi-starter-webflux-ui
+ ${springdoc.version}
diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/SpringDocConfig.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/SpringDocConfig.java
new file mode 100644
index 000000000..65ccbe9fc
--- /dev/null
+++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/SpringDocConfig.java
@@ -0,0 +1,93 @@
+package com.ruoyi.gateway.config;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.springdoc.core.properties.AbstractSwaggerUiConfigProperties;
+import org.springdoc.core.properties.SwaggerUiConfigProperties;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.context.annotation.Configuration;
+import com.alibaba.nacos.client.naming.event.InstancesChangeEvent;
+import com.alibaba.nacos.common.notify.Event;
+import com.alibaba.nacos.common.notify.NotifyCenter;
+import com.alibaba.nacos.common.notify.listener.Subscriber;
+import com.ruoyi.common.core.utils.StringUtils;
+
+/**
+ * SpringDoc配置类
+ *
+ * @author ruoyi
+ */
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnProperty(value = "springdoc.api-docs.enabled", matchIfMissing = true)
+public class SpringDocConfig implements InitializingBean
+{
+ @Autowired
+ private SwaggerUiConfigProperties swaggerUiConfigProperties;
+
+ @Autowired
+ private DiscoveryClient discoveryClient;
+
+ /**
+ * 在初始化后调用的方法
+ */
+ @Override
+ public void afterPropertiesSet()
+ {
+ NotifyCenter.registerSubscriber(new SwaggerDocRegister(swaggerUiConfigProperties, discoveryClient));
+ }
+}
+
+/**
+ * Swagger文档注册器
+ */
+class SwaggerDocRegister extends Subscriber
+{
+ @Autowired
+ private SwaggerUiConfigProperties swaggerUiConfigProperties;
+
+ @Autowired
+ private DiscoveryClient discoveryClient;
+
+ private final static String[] EXCLUDE_ROUTES = new String[] { "ruoyi-gateway", "ruoyi-auth", "ruoyi-file", "ruoyi-monitor" };
+
+ public SwaggerDocRegister(SwaggerUiConfigProperties swaggerUiConfigProperties, DiscoveryClient discoveryClient)
+ {
+ this.swaggerUiConfigProperties = swaggerUiConfigProperties;
+ this.discoveryClient = discoveryClient;
+ }
+
+ /**
+ * 事件回调方法,处理InstancesChangeEvent事件
+ * @param event 事件对象
+ */
+ @Override
+ public void onEvent(InstancesChangeEvent event)
+ {
+ Set swaggerUrlSet = discoveryClient.getServices()
+ .stream()
+ .flatMap(serviceId -> discoveryClient.getInstances(serviceId).stream())
+ .filter(instance -> !StringUtils.equalsAnyIgnoreCase(instance.getServiceId(), EXCLUDE_ROUTES))
+ .map(instance -> {
+ AbstractSwaggerUiConfigProperties.SwaggerUrl swaggerUrl = new AbstractSwaggerUiConfigProperties.SwaggerUrl();
+ swaggerUrl.setName(instance.getServiceId());
+ swaggerUrl.setUrl(String.format("/%s/v3/api-docs", instance.getServiceId()));
+ return swaggerUrl;
+ })
+ .collect(Collectors.toSet());
+
+ swaggerUiConfigProperties.setUrls(swaggerUrlSet);
+ }
+
+ /**
+ * 订阅类型方法,返回订阅的事件类型
+ * @return 订阅的事件类型
+ */
+ @Override
+ public Class extends Event> subscribeType()
+ {
+ return InstancesChangeEvent.class;
+ }
+}
diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/SwaggerProvider.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/SwaggerProvider.java
deleted file mode 100644
index 726673056..000000000
--- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/config/SwaggerProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.ruoyi.gateway.config;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.gateway.config.GatewayProperties;
-import org.springframework.cloud.gateway.route.RouteLocator;
-import org.springframework.cloud.gateway.support.NameUtils;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.stereotype.Component;
-import org.springframework.web.reactive.config.ResourceHandlerRegistry;
-import org.springframework.web.reactive.config.WebFluxConfigurer;
-import springfox.documentation.swagger.web.SwaggerResource;
-import springfox.documentation.swagger.web.SwaggerResourcesProvider;
-
-/**
- * 聚合系统接口
- *
- * @author ruoyi
- */
-@Component
-public class SwaggerProvider implements SwaggerResourcesProvider, WebFluxConfigurer
-{
- /**
- * Swagger2默认的url后缀
- */
- public static final String SWAGGER2URL = "/v2/api-docs";
-
- /**
- * 网关路由
- */
- @Lazy
- @Autowired
- private RouteLocator routeLocator;
-
- @Autowired
- private GatewayProperties gatewayProperties;
-
- /**
- * 聚合其他服务接口
- *
- * @return
- */
- @Override
- public List get()
- {
- List resourceList = new ArrayList<>();
- List routes = new ArrayList<>();
- // 获取网关中配置的route
- routeLocator.getRoutes().subscribe(route -> routes.add(route.getId()));
- gatewayProperties.getRoutes().stream()
- .filter(routeDefinition -> routes
- .contains(routeDefinition.getId()))
- .forEach(routeDefinition -> routeDefinition.getPredicates().stream()
- .filter(predicateDefinition -> "Path".equalsIgnoreCase(predicateDefinition.getName()))
- .filter(predicateDefinition -> !"ruoyi-auth".equalsIgnoreCase(routeDefinition.getId()))
- .forEach(predicateDefinition -> resourceList
- .add(swaggerResource(routeDefinition.getId(), predicateDefinition.getArgs()
- .get(NameUtils.GENERATED_NAME_PREFIX + "0").replace("/**", SWAGGER2URL)))));
- return resourceList;
- }
-
- private SwaggerResource swaggerResource(String name, String location)
- {
- SwaggerResource swaggerResource = new SwaggerResource();
- swaggerResource.setName(name);
- swaggerResource.setLocation(location);
- swaggerResource.setSwaggerVersion("2.0");
- return swaggerResource;
- }
-
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry)
- {
- /** swagger-ui 地址 */
- registry.addResourceHandler("/swagger-ui/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
- }
-}
diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
index 101de6386..9582f8af0 100644
--- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
+++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/AuthFilter.java
@@ -101,7 +101,7 @@ public class AuthFilter implements GlobalFilter, Ordered
private Mono unauthorizedResponse(ServerWebExchange exchange, String msg)
{
- log.error("[鉴权异常处理]请求路径:{}", exchange.getRequest().getPath());
+ log.error("[鉴权异常处理]请求路径:{},错误信息:{}", exchange.getRequest().getPath(), msg);
return ServletUtils.webFluxResponseWriter(exchange.getResponse(), msg, HttpStatus.UNAUTHORIZED);
}
diff --git a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/ValidateCodeFilter.java b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/ValidateCodeFilter.java
index 0e2d1bc63..22de0d323 100644
--- a/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/ValidateCodeFilter.java
+++ b/ruoyi-gateway/src/main/java/com/ruoyi/gateway/filter/ValidateCodeFilter.java
@@ -64,6 +64,7 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory