From 46e1f34b3e7f4cacb422cf2c4c41b0d8f03aa4a8 Mon Sep 17 00:00:00 2001 From: hsdllcw Date: Sat, 14 Dec 2024 16:42:37 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E5=8D=87=E7=BA=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=87=B33.6.5.0.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- pom.xml | 4 +- ruoyi-api/pom.xml | 2 +- ruoyi-api/ruoyi-api-system/pom.xml | 2 +- ruoyi-auth/pom.xml | 2 +- .../endpoint/web/WebEndpointProperties.java | 140 ++++++++++++++++++ .../servlet/WebMvcEndpointHandlerMapping.java | 113 ++++++++++++++ ruoyi-common/pom.xml | 2 +- ruoyi-common/ruoyi-common-core/pom.xml | 2 +- ruoyi-common/ruoyi-common-datascope/pom.xml | 2 +- ruoyi-common/ruoyi-common-datasource/pom.xml | 2 +- ruoyi-common/ruoyi-common-log/pom.xml | 2 +- ruoyi-common/ruoyi-common-redis/pom.xml | 2 +- ruoyi-common/ruoyi-common-seata/pom.xml | 2 +- ruoyi-common/ruoyi-common-security/pom.xml | 2 +- ruoyi-common/ruoyi-common-sensitive/pom.xml | 2 +- ruoyi-common/ruoyi-common-swagger/pom.xml | 2 +- ruoyi-gateway/pom.xml | 6 +- .../endpoint/web/WebEndpointProperties.java | 140 ++++++++++++++++++ .../servlet/WebMvcEndpointHandlerMapping.java | 113 ++++++++++++++ ruoyi-modules/pom.xml | 2 +- ruoyi-modules/ruoyi-file/pom.xml | 2 +- .../endpoint/web/WebEndpointProperties.java | 140 ++++++++++++++++++ .../servlet/WebMvcEndpointHandlerMapping.java | 113 ++++++++++++++ ruoyi-modules/ruoyi-gen/pom.xml | 2 +- .../endpoint/web/WebEndpointProperties.java | 140 ++++++++++++++++++ .../servlet/WebMvcEndpointHandlerMapping.java | 113 ++++++++++++++ ruoyi-modules/ruoyi-job/pom.xml | 2 +- .../endpoint/web/WebEndpointProperties.java | 140 ++++++++++++++++++ .../servlet/WebMvcEndpointHandlerMapping.java | 113 ++++++++++++++ ruoyi-modules/ruoyi-system/pom.xml | 2 +- .../endpoint/web/WebEndpointProperties.java | 140 ++++++++++++++++++ .../servlet/WebMvcEndpointHandlerMapping.java | 113 ++++++++++++++ ruoyi-ui/package.json | 2 +- ruoyi-ui/src/views/index.vue | 4 +- ruoyi-visual/pom.xml | 2 +- ruoyi-visual/ruoyi-monitor/pom.xml | 2 +- 37 files changed, 1550 insertions(+), 28 deletions(-) create mode 100644 ruoyi-auth/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java create mode 100644 ruoyi-auth/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java create mode 100644 ruoyi-gateway/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java create mode 100644 ruoyi-gateway/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java create mode 100644 ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java create mode 100644 ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java create mode 100644 ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java create mode 100644 ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java create mode 100644 ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java create mode 100644 ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java create mode 100644 ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java diff --git a/README.md b/README.md index 734f23739..c31947ad5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@

logo

-

RuoYi v3.6.5.0.3

+

RuoYi v3.6.5.0.4

基于 Vue/Element UI 和 Spring Boot/Spring Cloud & Alibaba 前后端分离的分布式微服务架构

- +

diff --git a/pom.xml b/pom.xml index 51e658bda..532c34a2c 100644 --- a/pom.xml +++ b/pom.xml @@ -6,14 +6,14 @@ com.ruoyi ruoyi - 3.6.5.0.3 + 3.6.5.0.4 ruoyi http://www.ruoyi.vip 若依微服务系统 - 3.6.5.0.3 + 3.6.5.0.4 UTF-8 UTF-8 1.8 diff --git a/ruoyi-api/pom.xml b/ruoyi-api/pom.xml index 7429dbaa2..72d6b010b 100644 --- a/ruoyi-api/pom.xml +++ b/ruoyi-api/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-api/ruoyi-api-system/pom.xml b/ruoyi-api/ruoyi-api-system/pom.xml index 6a72c67c9..68463a22e 100644 --- a/ruoyi-api/ruoyi-api-system/pom.xml +++ b/ruoyi-api/ruoyi-api-system/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-api - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-auth/pom.xml b/ruoyi-auth/pom.xml index 15c694a7f..c2aa296da 100644 --- a/ruoyi-auth/pom.xml +++ b/ruoyi-auth/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-auth/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/ruoyi-auth/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java new file mode 100644 index 000000000..68e35e6b1 --- /dev/null +++ b/ruoyi-auth/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -0,0 +1,140 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +/** + * Configuration properties for web management endpoints. + * + * @author Madhura Bhave + * @author Phillip Webb + * @since 2.0.0 + */ +@ConfigurationProperties(prefix = "management.endpoints.web") +public class WebEndpointProperties { + + private final Exposure exposure = new Exposure(); + + /** + * Base path for Web endpoints. Relative to the servlet context path + * (server.servlet.context-path) or WebFlux base path (spring.webflux.base-path) when + * the management server is sharing the main server port. Relative to the management + * server base path (management.server.base-path) when a separate management server + * port (management.server.port) is configured. + */ + private String basePath = "/actuator"; + private String baseUrl = null; + + /** + * Mapping between endpoint IDs and the path that should expose them. + */ + private final Map pathMapping = new LinkedHashMap<>(); + + private final Discovery discovery = new Discovery(); + + public Exposure getExposure() { + return this.exposure; + } + + public String getBasePath() { + return this.basePath; + } + + public void setBasePath(String basePath) { + Assert.isTrue(basePath.isEmpty() || basePath.startsWith("/"), "Base path must start with '/' or be empty"); + this.basePath = cleanBasePath(basePath); + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + private String cleanBasePath(String basePath) { + if (StringUtils.hasText(basePath) && basePath.endsWith("/")) { + return basePath.substring(0, basePath.length() - 1); + } + return basePath; + } + + public Map getPathMapping() { + return this.pathMapping; + } + + public Discovery getDiscovery() { + return this.discovery; + } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded or '*' for all. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + + public static class Discovery { + + /** + * Whether the discovery page is enabled. + */ + private boolean enabled = true; + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + } + +} diff --git a/ruoyi-auth/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java b/ruoyi-auth/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java new file mode 100644 index 000000000..1c7dae1bb --- /dev/null +++ b/ruoyi-auth/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.endpoint.web.servlet; + +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.actuate.endpoint.web.*; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.util.pattern.PathPatternParser; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * A custom {@link HandlerMapping} that makes web endpoints available over HTTP using + * Spring MVC. + * + * @author Andy Wilkinson + * @author Phillip Webb + * @since 2.0.0 + */ +public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping { + + private final EndpointLinksResolver linksResolver; + @Lazy + @Resource + private WebEndpointProperties webEndpointProperties; + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping); + this.linksResolver = linksResolver; + setOrder(-100); + } + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + * @param pathPatternParser the path pattern parser + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping, + PathPatternParser pathPatternParser) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping, + pathPatternParser); + this.linksResolver = linksResolver; + setOrder(-100); + } + + @Override + protected LinksHandler getLinksHandler() { + return new WebMvcLinksHandler(); + } + + /** + * Handler for root endpoint providing links. + */ + class WebMvcLinksHandler implements LinksHandler { + + @Override + @ResponseBody + public Map> links(HttpServletRequest request, HttpServletResponse response) { + return Collections.singletonMap("_links", + WebMvcEndpointHandlerMapping.this.linksResolver.resolveLinks(ObjectUtils.isEmpty(webEndpointProperties.getBaseUrl())?request.getRequestURL().toString():(webEndpointProperties.getBaseUrl()+webEndpointProperties.getBasePath()))); + } + + @Override + public String toString() { + return "Actuator root web endpoint"; + } + + } + +} diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml index fdc05e698..a8a51737c 100644 --- a/ruoyi-common/pom.xml +++ b/ruoyi-common/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-core/pom.xml b/ruoyi-common/ruoyi-common-core/pom.xml index 765fc2bc4..cbe1f6f59 100644 --- a/ruoyi-common/ruoyi-common-core/pom.xml +++ b/ruoyi-common/ruoyi-common-core/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-datascope/pom.xml b/ruoyi-common/ruoyi-common-datascope/pom.xml index 57a91a365..b023a9ec8 100644 --- a/ruoyi-common/ruoyi-common-datascope/pom.xml +++ b/ruoyi-common/ruoyi-common-datascope/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-datasource/pom.xml b/ruoyi-common/ruoyi-common-datasource/pom.xml index 277ac57f2..10e97265c 100644 --- a/ruoyi-common/ruoyi-common-datasource/pom.xml +++ b/ruoyi-common/ruoyi-common-datasource/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-log/pom.xml b/ruoyi-common/ruoyi-common-log/pom.xml index a462f58a4..ca13426f6 100644 --- a/ruoyi-common/ruoyi-common-log/pom.xml +++ b/ruoyi-common/ruoyi-common-log/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-redis/pom.xml b/ruoyi-common/ruoyi-common-redis/pom.xml index 115c2b9b0..28c31968d 100644 --- a/ruoyi-common/ruoyi-common-redis/pom.xml +++ b/ruoyi-common/ruoyi-common-redis/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-seata/pom.xml b/ruoyi-common/ruoyi-common-seata/pom.xml index 0bf5a6f39..bf70f84a9 100644 --- a/ruoyi-common/ruoyi-common-seata/pom.xml +++ b/ruoyi-common/ruoyi-common-seata/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-security/pom.xml b/ruoyi-common/ruoyi-common-security/pom.xml index 31b073aff..f0339ee07 100644 --- a/ruoyi-common/ruoyi-common-security/pom.xml +++ b/ruoyi-common/ruoyi-common-security/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-sensitive/pom.xml b/ruoyi-common/ruoyi-common-sensitive/pom.xml index a9bbef222..daaa4c956 100644 --- a/ruoyi-common/ruoyi-common-sensitive/pom.xml +++ b/ruoyi-common/ruoyi-common-sensitive/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-common/ruoyi-common-swagger/pom.xml b/ruoyi-common/ruoyi-common-swagger/pom.xml index a6968e919..7541d31eb 100644 --- a/ruoyi-common/ruoyi-common-swagger/pom.xml +++ b/ruoyi-common/ruoyi-common-swagger/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-common - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-gateway/pom.xml b/ruoyi-gateway/pom.xml index 2bd076e3d..cfc52654f 100644 --- a/ruoyi-gateway/pom.xml +++ b/ruoyi-gateway/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 @@ -104,6 +104,10 @@ ${springdoc.version} + + org.springframework + spring-webmvc + de.codecentric spring-boot-admin-starter-client diff --git a/ruoyi-gateway/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/ruoyi-gateway/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java new file mode 100644 index 000000000..68e35e6b1 --- /dev/null +++ b/ruoyi-gateway/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -0,0 +1,140 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +/** + * Configuration properties for web management endpoints. + * + * @author Madhura Bhave + * @author Phillip Webb + * @since 2.0.0 + */ +@ConfigurationProperties(prefix = "management.endpoints.web") +public class WebEndpointProperties { + + private final Exposure exposure = new Exposure(); + + /** + * Base path for Web endpoints. Relative to the servlet context path + * (server.servlet.context-path) or WebFlux base path (spring.webflux.base-path) when + * the management server is sharing the main server port. Relative to the management + * server base path (management.server.base-path) when a separate management server + * port (management.server.port) is configured. + */ + private String basePath = "/actuator"; + private String baseUrl = null; + + /** + * Mapping between endpoint IDs and the path that should expose them. + */ + private final Map pathMapping = new LinkedHashMap<>(); + + private final Discovery discovery = new Discovery(); + + public Exposure getExposure() { + return this.exposure; + } + + public String getBasePath() { + return this.basePath; + } + + public void setBasePath(String basePath) { + Assert.isTrue(basePath.isEmpty() || basePath.startsWith("/"), "Base path must start with '/' or be empty"); + this.basePath = cleanBasePath(basePath); + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + private String cleanBasePath(String basePath) { + if (StringUtils.hasText(basePath) && basePath.endsWith("/")) { + return basePath.substring(0, basePath.length() - 1); + } + return basePath; + } + + public Map getPathMapping() { + return this.pathMapping; + } + + public Discovery getDiscovery() { + return this.discovery; + } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded or '*' for all. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + + public static class Discovery { + + /** + * Whether the discovery page is enabled. + */ + private boolean enabled = true; + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + } + +} diff --git a/ruoyi-gateway/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java b/ruoyi-gateway/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java new file mode 100644 index 000000000..1c7dae1bb --- /dev/null +++ b/ruoyi-gateway/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.endpoint.web.servlet; + +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.actuate.endpoint.web.*; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.util.pattern.PathPatternParser; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * A custom {@link HandlerMapping} that makes web endpoints available over HTTP using + * Spring MVC. + * + * @author Andy Wilkinson + * @author Phillip Webb + * @since 2.0.0 + */ +public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping { + + private final EndpointLinksResolver linksResolver; + @Lazy + @Resource + private WebEndpointProperties webEndpointProperties; + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping); + this.linksResolver = linksResolver; + setOrder(-100); + } + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + * @param pathPatternParser the path pattern parser + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping, + PathPatternParser pathPatternParser) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping, + pathPatternParser); + this.linksResolver = linksResolver; + setOrder(-100); + } + + @Override + protected LinksHandler getLinksHandler() { + return new WebMvcLinksHandler(); + } + + /** + * Handler for root endpoint providing links. + */ + class WebMvcLinksHandler implements LinksHandler { + + @Override + @ResponseBody + public Map> links(HttpServletRequest request, HttpServletResponse response) { + return Collections.singletonMap("_links", + WebMvcEndpointHandlerMapping.this.linksResolver.resolveLinks(ObjectUtils.isEmpty(webEndpointProperties.getBaseUrl())?request.getRequestURL().toString():(webEndpointProperties.getBaseUrl()+webEndpointProperties.getBasePath()))); + } + + @Override + public String toString() { + return "Actuator root web endpoint"; + } + + } + +} diff --git a/ruoyi-modules/pom.xml b/ruoyi-modules/pom.xml index 947a06244..275cbed75 100644 --- a/ruoyi-modules/pom.xml +++ b/ruoyi-modules/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-modules/ruoyi-file/pom.xml b/ruoyi-modules/ruoyi-file/pom.xml index ade44c28e..a7198c69e 100644 --- a/ruoyi-modules/ruoyi-file/pom.xml +++ b/ruoyi-modules/ruoyi-file/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-modules - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java new file mode 100644 index 000000000..68e35e6b1 --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -0,0 +1,140 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +/** + * Configuration properties for web management endpoints. + * + * @author Madhura Bhave + * @author Phillip Webb + * @since 2.0.0 + */ +@ConfigurationProperties(prefix = "management.endpoints.web") +public class WebEndpointProperties { + + private final Exposure exposure = new Exposure(); + + /** + * Base path for Web endpoints. Relative to the servlet context path + * (server.servlet.context-path) or WebFlux base path (spring.webflux.base-path) when + * the management server is sharing the main server port. Relative to the management + * server base path (management.server.base-path) when a separate management server + * port (management.server.port) is configured. + */ + private String basePath = "/actuator"; + private String baseUrl = null; + + /** + * Mapping between endpoint IDs and the path that should expose them. + */ + private final Map pathMapping = new LinkedHashMap<>(); + + private final Discovery discovery = new Discovery(); + + public Exposure getExposure() { + return this.exposure; + } + + public String getBasePath() { + return this.basePath; + } + + public void setBasePath(String basePath) { + Assert.isTrue(basePath.isEmpty() || basePath.startsWith("/"), "Base path must start with '/' or be empty"); + this.basePath = cleanBasePath(basePath); + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + private String cleanBasePath(String basePath) { + if (StringUtils.hasText(basePath) && basePath.endsWith("/")) { + return basePath.substring(0, basePath.length() - 1); + } + return basePath; + } + + public Map getPathMapping() { + return this.pathMapping; + } + + public Discovery getDiscovery() { + return this.discovery; + } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded or '*' for all. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + + public static class Discovery { + + /** + * Whether the discovery page is enabled. + */ + private boolean enabled = true; + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + } + +} diff --git a/ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java b/ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java new file mode 100644 index 000000000..1c7dae1bb --- /dev/null +++ b/ruoyi-modules/ruoyi-file/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.endpoint.web.servlet; + +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.actuate.endpoint.web.*; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.util.pattern.PathPatternParser; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * A custom {@link HandlerMapping} that makes web endpoints available over HTTP using + * Spring MVC. + * + * @author Andy Wilkinson + * @author Phillip Webb + * @since 2.0.0 + */ +public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping { + + private final EndpointLinksResolver linksResolver; + @Lazy + @Resource + private WebEndpointProperties webEndpointProperties; + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping); + this.linksResolver = linksResolver; + setOrder(-100); + } + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + * @param pathPatternParser the path pattern parser + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping, + PathPatternParser pathPatternParser) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping, + pathPatternParser); + this.linksResolver = linksResolver; + setOrder(-100); + } + + @Override + protected LinksHandler getLinksHandler() { + return new WebMvcLinksHandler(); + } + + /** + * Handler for root endpoint providing links. + */ + class WebMvcLinksHandler implements LinksHandler { + + @Override + @ResponseBody + public Map> links(HttpServletRequest request, HttpServletResponse response) { + return Collections.singletonMap("_links", + WebMvcEndpointHandlerMapping.this.linksResolver.resolveLinks(ObjectUtils.isEmpty(webEndpointProperties.getBaseUrl())?request.getRequestURL().toString():(webEndpointProperties.getBaseUrl()+webEndpointProperties.getBasePath()))); + } + + @Override + public String toString() { + return "Actuator root web endpoint"; + } + + } + +} diff --git a/ruoyi-modules/ruoyi-gen/pom.xml b/ruoyi-modules/ruoyi-gen/pom.xml index 3b83be85b..c82ccdf00 100644 --- a/ruoyi-modules/ruoyi-gen/pom.xml +++ b/ruoyi-modules/ruoyi-gen/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-modules - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java new file mode 100644 index 000000000..68e35e6b1 --- /dev/null +++ b/ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -0,0 +1,140 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +/** + * Configuration properties for web management endpoints. + * + * @author Madhura Bhave + * @author Phillip Webb + * @since 2.0.0 + */ +@ConfigurationProperties(prefix = "management.endpoints.web") +public class WebEndpointProperties { + + private final Exposure exposure = new Exposure(); + + /** + * Base path for Web endpoints. Relative to the servlet context path + * (server.servlet.context-path) or WebFlux base path (spring.webflux.base-path) when + * the management server is sharing the main server port. Relative to the management + * server base path (management.server.base-path) when a separate management server + * port (management.server.port) is configured. + */ + private String basePath = "/actuator"; + private String baseUrl = null; + + /** + * Mapping between endpoint IDs and the path that should expose them. + */ + private final Map pathMapping = new LinkedHashMap<>(); + + private final Discovery discovery = new Discovery(); + + public Exposure getExposure() { + return this.exposure; + } + + public String getBasePath() { + return this.basePath; + } + + public void setBasePath(String basePath) { + Assert.isTrue(basePath.isEmpty() || basePath.startsWith("/"), "Base path must start with '/' or be empty"); + this.basePath = cleanBasePath(basePath); + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + private String cleanBasePath(String basePath) { + if (StringUtils.hasText(basePath) && basePath.endsWith("/")) { + return basePath.substring(0, basePath.length() - 1); + } + return basePath; + } + + public Map getPathMapping() { + return this.pathMapping; + } + + public Discovery getDiscovery() { + return this.discovery; + } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded or '*' for all. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + + public static class Discovery { + + /** + * Whether the discovery page is enabled. + */ + private boolean enabled = true; + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + } + +} diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java b/ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java new file mode 100644 index 000000000..1c7dae1bb --- /dev/null +++ b/ruoyi-modules/ruoyi-gen/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.endpoint.web.servlet; + +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.actuate.endpoint.web.*; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.util.pattern.PathPatternParser; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * A custom {@link HandlerMapping} that makes web endpoints available over HTTP using + * Spring MVC. + * + * @author Andy Wilkinson + * @author Phillip Webb + * @since 2.0.0 + */ +public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping { + + private final EndpointLinksResolver linksResolver; + @Lazy + @Resource + private WebEndpointProperties webEndpointProperties; + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping); + this.linksResolver = linksResolver; + setOrder(-100); + } + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + * @param pathPatternParser the path pattern parser + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping, + PathPatternParser pathPatternParser) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping, + pathPatternParser); + this.linksResolver = linksResolver; + setOrder(-100); + } + + @Override + protected LinksHandler getLinksHandler() { + return new WebMvcLinksHandler(); + } + + /** + * Handler for root endpoint providing links. + */ + class WebMvcLinksHandler implements LinksHandler { + + @Override + @ResponseBody + public Map> links(HttpServletRequest request, HttpServletResponse response) { + return Collections.singletonMap("_links", + WebMvcEndpointHandlerMapping.this.linksResolver.resolveLinks(ObjectUtils.isEmpty(webEndpointProperties.getBaseUrl())?request.getRequestURL().toString():(webEndpointProperties.getBaseUrl()+webEndpointProperties.getBasePath()))); + } + + @Override + public String toString() { + return "Actuator root web endpoint"; + } + + } + +} diff --git a/ruoyi-modules/ruoyi-job/pom.xml b/ruoyi-modules/ruoyi-job/pom.xml index caa46ad3a..a23fb06b4 100644 --- a/ruoyi-modules/ruoyi-job/pom.xml +++ b/ruoyi-modules/ruoyi-job/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-modules - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java new file mode 100644 index 000000000..68e35e6b1 --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -0,0 +1,140 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +/** + * Configuration properties for web management endpoints. + * + * @author Madhura Bhave + * @author Phillip Webb + * @since 2.0.0 + */ +@ConfigurationProperties(prefix = "management.endpoints.web") +public class WebEndpointProperties { + + private final Exposure exposure = new Exposure(); + + /** + * Base path for Web endpoints. Relative to the servlet context path + * (server.servlet.context-path) or WebFlux base path (spring.webflux.base-path) when + * the management server is sharing the main server port. Relative to the management + * server base path (management.server.base-path) when a separate management server + * port (management.server.port) is configured. + */ + private String basePath = "/actuator"; + private String baseUrl = null; + + /** + * Mapping between endpoint IDs and the path that should expose them. + */ + private final Map pathMapping = new LinkedHashMap<>(); + + private final Discovery discovery = new Discovery(); + + public Exposure getExposure() { + return this.exposure; + } + + public String getBasePath() { + return this.basePath; + } + + public void setBasePath(String basePath) { + Assert.isTrue(basePath.isEmpty() || basePath.startsWith("/"), "Base path must start with '/' or be empty"); + this.basePath = cleanBasePath(basePath); + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + private String cleanBasePath(String basePath) { + if (StringUtils.hasText(basePath) && basePath.endsWith("/")) { + return basePath.substring(0, basePath.length() - 1); + } + return basePath; + } + + public Map getPathMapping() { + return this.pathMapping; + } + + public Discovery getDiscovery() { + return this.discovery; + } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded or '*' for all. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + + public static class Discovery { + + /** + * Whether the discovery page is enabled. + */ + private boolean enabled = true; + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + } + +} diff --git a/ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java b/ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java new file mode 100644 index 000000000..1c7dae1bb --- /dev/null +++ b/ruoyi-modules/ruoyi-job/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.endpoint.web.servlet; + +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.actuate.endpoint.web.*; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.util.pattern.PathPatternParser; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * A custom {@link HandlerMapping} that makes web endpoints available over HTTP using + * Spring MVC. + * + * @author Andy Wilkinson + * @author Phillip Webb + * @since 2.0.0 + */ +public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping { + + private final EndpointLinksResolver linksResolver; + @Lazy + @Resource + private WebEndpointProperties webEndpointProperties; + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping); + this.linksResolver = linksResolver; + setOrder(-100); + } + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + * @param pathPatternParser the path pattern parser + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping, + PathPatternParser pathPatternParser) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping, + pathPatternParser); + this.linksResolver = linksResolver; + setOrder(-100); + } + + @Override + protected LinksHandler getLinksHandler() { + return new WebMvcLinksHandler(); + } + + /** + * Handler for root endpoint providing links. + */ + class WebMvcLinksHandler implements LinksHandler { + + @Override + @ResponseBody + public Map> links(HttpServletRequest request, HttpServletResponse response) { + return Collections.singletonMap("_links", + WebMvcEndpointHandlerMapping.this.linksResolver.resolveLinks(ObjectUtils.isEmpty(webEndpointProperties.getBaseUrl())?request.getRequestURL().toString():(webEndpointProperties.getBaseUrl()+webEndpointProperties.getBasePath()))); + } + + @Override + public String toString() { + return "Actuator root web endpoint"; + } + + } + +} diff --git a/ruoyi-modules/ruoyi-system/pom.xml b/ruoyi-modules/ruoyi-system/pom.xml index b97fef1e1..118a9c9f4 100644 --- a/ruoyi-modules/ruoyi-system/pom.xml +++ b/ruoyi-modules/ruoyi-system/pom.xml @@ -5,7 +5,7 @@ com.ruoyi ruoyi-modules - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java b/ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java new file mode 100644 index 000000000..68e35e6b1 --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointProperties.java @@ -0,0 +1,140 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.endpoint.web; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +/** + * Configuration properties for web management endpoints. + * + * @author Madhura Bhave + * @author Phillip Webb + * @since 2.0.0 + */ +@ConfigurationProperties(prefix = "management.endpoints.web") +public class WebEndpointProperties { + + private final Exposure exposure = new Exposure(); + + /** + * Base path for Web endpoints. Relative to the servlet context path + * (server.servlet.context-path) or WebFlux base path (spring.webflux.base-path) when + * the management server is sharing the main server port. Relative to the management + * server base path (management.server.base-path) when a separate management server + * port (management.server.port) is configured. + */ + private String basePath = "/actuator"; + private String baseUrl = null; + + /** + * Mapping between endpoint IDs and the path that should expose them. + */ + private final Map pathMapping = new LinkedHashMap<>(); + + private final Discovery discovery = new Discovery(); + + public Exposure getExposure() { + return this.exposure; + } + + public String getBasePath() { + return this.basePath; + } + + public void setBasePath(String basePath) { + Assert.isTrue(basePath.isEmpty() || basePath.startsWith("/"), "Base path must start with '/' or be empty"); + this.basePath = cleanBasePath(basePath); + } + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + private String cleanBasePath(String basePath) { + if (StringUtils.hasText(basePath) && basePath.endsWith("/")) { + return basePath.substring(0, basePath.length() - 1); + } + return basePath; + } + + public Map getPathMapping() { + return this.pathMapping; + } + + public Discovery getDiscovery() { + return this.discovery; + } + + public static class Exposure { + + /** + * Endpoint IDs that should be included or '*' for all. + */ + private Set include = new LinkedHashSet<>(); + + /** + * Endpoint IDs that should be excluded or '*' for all. + */ + private Set exclude = new LinkedHashSet<>(); + + public Set getInclude() { + return this.include; + } + + public void setInclude(Set include) { + this.include = include; + } + + public Set getExclude() { + return this.exclude; + } + + public void setExclude(Set exclude) { + this.exclude = exclude; + } + + } + + public static class Discovery { + + /** + * Whether the discovery page is enabled. + */ + private boolean enabled = true; + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + } + +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java b/ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java new file mode 100644 index 000000000..1c7dae1bb --- /dev/null +++ b/ruoyi-modules/ruoyi-system/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java @@ -0,0 +1,113 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.endpoint.web.servlet; + +import org.apache.commons.lang3.ObjectUtils; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.actuate.endpoint.web.*; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.servlet.HandlerMapping; +import org.springframework.web.util.pattern.PathPatternParser; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +/** + * A custom {@link HandlerMapping} that makes web endpoints available over HTTP using + * Spring MVC. + * + * @author Andy Wilkinson + * @author Phillip Webb + * @since 2.0.0 + */ +public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping { + + private final EndpointLinksResolver linksResolver; + @Lazy + @Resource + private WebEndpointProperties webEndpointProperties; + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping); + this.linksResolver = linksResolver; + setOrder(-100); + } + + /** + * Creates a new {@code WebMvcEndpointHandlerMapping} instance that provides mappings + * for the given endpoints. + * @param endpointMapping the base mapping for all endpoints + * @param endpoints the web endpoints + * @param endpointMediaTypes media types consumed and produced by the endpoints + * @param corsConfiguration the CORS configuration for the endpoints or {@code null} + * @param linksResolver resolver for determining links to available endpoints + * @param shouldRegisterLinksMapping whether the links endpoint should be registered + * @param pathPatternParser the path pattern parser + */ + public WebMvcEndpointHandlerMapping(EndpointMapping endpointMapping, Collection endpoints, + EndpointMediaTypes endpointMediaTypes, CorsConfiguration corsConfiguration, + EndpointLinksResolver linksResolver, boolean shouldRegisterLinksMapping, + PathPatternParser pathPatternParser) { + super(endpointMapping, endpoints, endpointMediaTypes, corsConfiguration, shouldRegisterLinksMapping, + pathPatternParser); + this.linksResolver = linksResolver; + setOrder(-100); + } + + @Override + protected LinksHandler getLinksHandler() { + return new WebMvcLinksHandler(); + } + + /** + * Handler for root endpoint providing links. + */ + class WebMvcLinksHandler implements LinksHandler { + + @Override + @ResponseBody + public Map> links(HttpServletRequest request, HttpServletResponse response) { + return Collections.singletonMap("_links", + WebMvcEndpointHandlerMapping.this.linksResolver.resolveLinks(ObjectUtils.isEmpty(webEndpointProperties.getBaseUrl())?request.getRequestURL().toString():(webEndpointProperties.getBaseUrl()+webEndpointProperties.getBasePath()))); + } + + @Override + public String toString() { + return "Actuator root web endpoint"; + } + + } + +} diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 731766049..cb70d2e7b 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi", - "version": "3.6.5.0.3", + "version": "3.6.5.0.4", "description": "若依管理系统", "author": "若依", "license": "MIT", diff --git a/ruoyi-ui/src/views/index.vue b/ruoyi-ui/src/views/index.vue index 081400843..7fa6a0c16 100644 --- a/ruoyi-ui/src/views/index.vue +++ b/ruoyi-ui/src/views/index.vue @@ -145,7 +145,7 @@ 更新日志 - +
  1. 使用SpringDoc代替Swagger
  2. 菜单管理新增路由名称
  3. @@ -946,7 +946,7 @@ export default { data() { return { // 版本号 - version: "3.6.5.0.3", + version: "3.6.5.0.4", }; }, methods: { diff --git a/ruoyi-visual/pom.xml b/ruoyi-visual/pom.xml index 22b3055d1..57bcd63ed 100644 --- a/ruoyi-visual/pom.xml +++ b/ruoyi-visual/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi - 3.6.5.0.3 + 3.6.5.0.4 4.0.0 diff --git a/ruoyi-visual/ruoyi-monitor/pom.xml b/ruoyi-visual/ruoyi-monitor/pom.xml index 323074d6d..1fa7071e5 100644 --- a/ruoyi-visual/ruoyi-monitor/pom.xml +++ b/ruoyi-visual/ruoyi-monitor/pom.xml @@ -4,7 +4,7 @@ com.ruoyi ruoyi-visual - 3.6.5.0.3 + 3.6.5.0.4 4.0.0