update 升级 jdk 17

update springboot 3.0.7
update springcloud 2022.0.2
update springcloud-alibaba 2022.0.0.0-RC2
update springboot-admin 3.0.4
update springdoc 2.1.0
update dynamic-ds 3.6.1
add flatten-maven-plugin
update javax -> jakarta
...........未完待续
This commit is contained in:
疯狂的狮子li
2023-05-22 18:45:16 +08:00
parent d3130cf055
commit 55c3e7687b
89 changed files with 1760 additions and 262 deletions

View File

@@ -8,12 +8,15 @@ import io.swagger.v3.oas.models.Paths;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.*;
import org.springdoc.core.configuration.SpringDocConfiguration;
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
import org.springdoc.core.customizers.OpenApiCustomiser;
import org.springdoc.core.customizers.OpenApiCustomizer;
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
import org.springdoc.core.properties.SpringDocConfigProperties;
import org.springdoc.core.providers.JavadocProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springdoc.core.service.OpenAPIService;
import org.springdoc.core.service.SecurityService;
import org.springdoc.core.utils.PropertyResolverUtils;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -21,7 +24,10 @@ import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* Swagger 文档配置
@@ -34,16 +40,11 @@ import java.util.*;
@ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true", matchIfMissing = true)
public class SwaggerAutoConfiguration {
private final SwaggerProperties swaggerProperties;
private final ServerProperties serverProperties;
@Value("${spring.application.name}")
private String appName;
@Bean
@ConditionalOnMissingBean(OpenAPI.class)
public OpenAPI openApi() {
public OpenAPI openApi(SwaggerProperties swaggerProperties) {
OpenAPI openApi = new OpenAPI();
// 文档基本信息
SwaggerProperties.InfoProperties infoProperties = swaggerProperties.getInfo();
@@ -90,22 +91,13 @@ public class SwaggerAutoConfiguration {
* 对已经生成好的 OpenApi 进行自定义操作
*/
@Bean
public OpenApiCustomiser openApiCustomiser() {
// 如果服务的自定义 Path 不存在 则采用默认去除前缀当 Path
Map<String, String> serviceMapping = swaggerProperties.getServiceMapping();
String appPath;
if (serviceMapping.containsKey(appName)) {
appPath = serviceMapping.get(appName);
} else {
appPath = "/" + StringUtils.substring(appName, appName.indexOf("-") + 1);
}
public OpenApiCustomizer openApiCustomizer() {
String contextPath = serverProperties.getServlet().getContextPath();
String finalContextPath;
if (StringUtils.isBlank(contextPath) || "/".equals(contextPath)) {
finalContextPath = appPath;
finalContextPath = "";
} else {
finalContextPath = appPath + contextPath;
finalContextPath = contextPath;
}
// 对所有路径增加前置上下文路径
return openApi -> {
@@ -114,7 +106,7 @@ public class SwaggerAutoConfiguration {
return;
}
PlusPaths newPaths = new PlusPaths();
oldPaths.forEach((k,v) -> newPaths.addPathItem(finalContextPath + k, v));
oldPaths.forEach((k, v) -> newPaths.addPathItem(finalContextPath + k, v));
openApi.setPaths(newPaths);
};
}

View File

@@ -11,7 +11,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import java.util.List;
import java.util.Map;
/**
* swagger 配置属性
@@ -51,12 +50,6 @@ public class SwaggerProperties {
@NestedConfigurationProperty
private Components components = null;
/**
* 服务文档路径映射 参考 gateway router 配置
* 默认为服务名去除前缀转换为path 此处填特殊的配置
*/
private Map<String, String> serviceMapping = null;
/**
* <p>
* 文档的基础属性信息

View File

@@ -9,16 +9,15 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.Paths;
import io.swagger.v3.oas.models.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.OpenAPIService;
import org.springdoc.core.PropertyResolverUtils;
import org.springdoc.core.SecurityService;
import org.springdoc.core.SpringDocConfigProperties;
import org.springdoc.core.customizers.OpenApiBuilderCustomizer;
import org.springdoc.core.customizers.ServerBaseUrlCustomizer;
import org.springdoc.core.properties.SpringDocConfigProperties;
import org.springdoc.core.providers.JavadocProvider;
import org.springdoc.core.service.OpenAPIService;
import org.springdoc.core.service.SecurityService;
import org.springdoc.core.utils.PropertyResolverUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.util.CollectionUtils;
@@ -34,18 +33,14 @@ import java.util.stream.Stream;
* 自定义 openapi 处理器
* 对源码功能进行修改 增强使用
*/
@Slf4j
@SuppressWarnings("all")
public class OpenApiHandler extends OpenAPIService {
/**
* The constant LOGGER.
* The Basic error controller.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(OpenAPIService.class);
/**
* The Context.
*/
private ApplicationContext context;
private static Class<?> basicErrorController;
/**
* The Security parser.
@@ -77,26 +72,11 @@ public class OpenApiHandler extends OpenAPIService {
*/
private final SpringDocConfigProperties springDocConfigProperties;
/**
* The Open api.
*/
private OpenAPI openAPI;
/**
* The Cached open api map.
*/
private final Map<String, OpenAPI> cachedOpenAPI = new HashMap<>();
/**
* The Is servers present.
*/
private boolean isServersPresent;
/**
* The Server base url.
*/
private String serverBaseUrl;
/**
* The Property resolver utils.
*/
@@ -108,24 +88,24 @@ public class OpenApiHandler extends OpenAPIService {
private final Optional<JavadocProvider> javadocProvider;
/**
* The Basic error controller.
* The Context.
*/
private static Class<?> basicErrorController;
private ApplicationContext context;
static {
try {
//spring-boot 2
basicErrorController = Class.forName("org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController");
} catch (ClassNotFoundException e) {
//spring-boot 1
try {
basicErrorController = Class.forName("org.springframework.boot.autoconfigure.web.BasicErrorController");
} catch (ClassNotFoundException classNotFoundException) {
//Basic error controller class not found
LOGGER.trace(classNotFoundException.getMessage());
}
}
}
/**
* The Open api.
*/
private OpenAPI openAPI;
/**
* The Is servers present.
*/
private boolean isServersPresent;
/**
* The Server base url.
*/
private String serverBaseUrl;
/**
* Instantiates a new Open api builder.