From 38922dbcc3b5a95e84a02e4a63d8b48fbc9c401a Mon Sep 17 00:00:00 2001 From: Parker Date: Fri, 18 Sep 2020 16:25:33 +0800 Subject: [PATCH] =?UTF-8?q?Api=20Controller=20=E7=BB=9F=E4=B8=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opsli/core/conf/SpringWebMvcConfig.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 opsli-core/src/main/java/org/opsli/core/conf/SpringWebMvcConfig.java diff --git a/opsli-core/src/main/java/org/opsli/core/conf/SpringWebMvcConfig.java b/opsli-core/src/main/java/org/opsli/core/conf/SpringWebMvcConfig.java new file mode 100644 index 0000000..f3f9b8c --- /dev/null +++ b/opsli-core/src/main/java/org/opsli/core/conf/SpringWebMvcConfig.java @@ -0,0 +1,27 @@ +package org.opsli.core.conf; + +import org.opsli.common.annotation.ApiRestController; +import org.opsli.core.prop.ApiPathProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import javax.annotation.Resource; + +/** + * 配置统一的后台接口访问路径的前缀 + * @author C西 + */ +@Configuration +public class SpringWebMvcConfig implements WebMvcConfigurer { + + @Resource + private ApiPathProperties apiPathProperties; + + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + configurer + .addPathPrefix(apiPathProperties.getGlobalPrefix(),c -> c.isAnnotationPresent(ApiRestController.class)); + } + +}