2
0
MaxKey 1 жил өмнө
parent
commit
fc7c8fd2ef

+ 40 - 0
maxkey-core/src/main/java/org/dromara/maxkey/autoconfigure/ResourceMvcConfig.java

@@ -0,0 +1,40 @@
+package org.dromara.maxkey.autoconfigure;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@EnableWebMvc
+@AutoConfiguration
+public class ResourceMvcConfig implements WebMvcConfigurer {
+    private static final  Logger logger = LoggerFactory.getLogger(ResourceMvcConfig.class);
+
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+    	logger.debug("add Resource Handlers");
+    	
+        logger.debug("add statics");
+        registry.addResourceHandler("/static/**")
+                .addResourceLocations("classpath:/static/");
+        
+        logger.debug("add templates");
+        registry.addResourceHandler("/templates/**")
+                .addResourceLocations("classpath:/templates/");
+        
+        logger.debug("add swagger");
+        registry.addResourceHandler("swagger-ui.html")
+                .addResourceLocations("classpath:/META-INF/resources/");
+        
+        logger.debug("add knife4j");
+        registry.addResourceHandler("doc.html")
+        		.addResourceLocations("classpath:/META-INF/resources/");
+        
+        registry.addResourceHandler("/webjars/**")
+        		.addResourceLocations("classpath:/META-INF/resources/webjars/");
+        
+        logger.debug("add Resource Handler finished .");
+    }
+}

+ 0 - 26
maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMvcConfig.java

@@ -38,7 +38,6 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
 @EnableWebMvc
@@ -72,31 +71,6 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
     
     @Autowired
     HistorySignOnAppInterceptor historySignOnAppInterceptor;
-    
-    @Override
-    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-    	logger.debug("add Resource Handlers");
-        logger.debug("add statics");
-        registry.addResourceHandler("/static/**")
-                .addResourceLocations("classpath:/static/");
-        
-        logger.debug("add templates");
-        registry.addResourceHandler("/templates/**")
-                .addResourceLocations("classpath:/templates/");
-        
-        logger.debug("add swagger");
-        registry.addResourceHandler("swagger-ui.html")
-                .addResourceLocations("classpath:/META-INF/resources/");
-        
-        logger.debug("add knife4j");
-        registry.addResourceHandler("doc.html")
-        		.addResourceLocations("classpath:/META-INF/resources/");
-        
-        registry.addResourceHandler("/webjars/**")
-        		.addResourceLocations("classpath:/META-INF/resources/webjars/");
-        
-        logger.debug("add Resource Handler finished .");
-    }
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {

+ 1 - 0
maxkey-webs/maxkey-web-maxkey/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -10,6 +10,7 @@ org.dromara.maxkey.autoconfigure.SessionAutoConfiguration
 org.dromara.maxkey.autoconfigure.TokenAutoConfiguration
 org.dromara.maxkey.autoconfigure.CasAutoConfiguration
 org.dromara.maxkey.autoconfigure.Oauth20AutoConfiguration
+org.dromara.maxkey.autoconfigure.ResourceMvcConfig
 org.dromara.maxkey.autoconfigure.Saml20AutoConfiguration
 org.dromara.maxkey.autoconfigure.SocialSignOnAutoConfiguration
 org.dromara.maxkey.autoconfigure.SwaggerConfig

+ 0 - 25
maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMgtMvcConfig.java

@@ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
 import org.springframework.context.annotation.Bean;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 
@@ -47,30 +46,6 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
     
     @Autowired
     PermissionInterceptor permissionInterceptor;
-    
-    @Override
-    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-    	logger.debug("add Resource Handlers");
-    	 
-        logger.debug("add statics");
-        registry.addResourceHandler("/static/**")
-                .addResourceLocations("classpath:/static/");
-        logger.debug("add templates");
-        registry.addResourceHandler("/templates/**")
-                .addResourceLocations("classpath:/templates/");
-        
-        logger.debug("add swagger");
-        registry.addResourceHandler("swagger-ui.html")
-                .addResourceLocations("classpath:/META-INF/resources/");
-        registry.addResourceHandler("/webjars/**")
-                .addResourceLocations("classpath:/META-INF/resources/webjars/");
-        
-        logger.debug("add knife4j");
-        registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
-        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
-
-        logger.debug("add Resource Handler finished .");
-    }
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {

+ 1 - 0
maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -8,6 +8,7 @@ org.dromara.maxkey.autoconfigure.OneTimePasswordAutoConfiguration
 org.dromara.maxkey.autoconfigure.SmsAutoConfiguration
 org.dromara.maxkey.autoconfigure.SessionAutoConfiguration
 org.dromara.maxkey.autoconfigure.TokenAutoConfiguration
+org.dromara.maxkey.autoconfigure.ResourceMvcConfig
 org.dromara.maxkey.autoconfigure.SynchronizerAutoConfiguration
 org.dromara.maxkey.autoconfigure.SwaggerConfig
 org.dromara.maxkey.autoconfigure.Oauth20ClientAutoConfiguration

+ 0 - 25
maxkey-webs/maxkey-web-openapi/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyOpenApiMvcConfig.java

@@ -31,7 +31,6 @@ import org.springframework.boot.autoconfigure.AutoConfiguration;
 import org.springframework.context.annotation.Bean;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 import org.springframework.web.method.support.HandlerMethodArgumentResolver;
 
@@ -51,30 +50,6 @@ public class MaxKeyOpenApiMvcConfig implements WebMvcConfigurer {
     
     @Autowired
     RestApiPermissionAdapter restApiPermissionAdapter;
-    
-    @Override
-    public void addResourceHandlers(ResourceHandlerRegistry registry) {
-    	logger.debug("add Resource Handlers");
-    	 
-        logger.debug("add statics");
-        registry.addResourceHandler("/static/**")
-                .addResourceLocations("classpath:/static/");
-        logger.debug("add templates");
-        registry.addResourceHandler("/templates/**")
-                .addResourceLocations("classpath:/templates/");
-        
-        logger.debug("add swagger");
-        registry.addResourceHandler("swagger-ui.html")
-                .addResourceLocations("classpath:/META-INF/resources/");
-        registry.addResourceHandler("/webjars/**")
-                .addResourceLocations("classpath:/META-INF/resources/webjars/");
-        
-        logger.debug("add knife4j");
-        registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
-        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
-
-        logger.debug("add Resource Handler finished .");
-    }
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {

+ 1 - 0
maxkey-webs/maxkey-web-openapi/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

@@ -5,6 +5,7 @@ org.dromara.maxkey.autoconfigure.JwtAuthnAutoConfiguration
 org.dromara.maxkey.autoconfigure.RedisAutoConfiguration
 org.dromara.maxkey.autoconfigure.AuthnProviderAutoConfiguration
 org.dromara.maxkey.autoconfigure.OneTimePasswordAutoConfiguration
+org.dromara.maxkey.autoconfigure.ResourceMvcConfig
 org.dromara.maxkey.autoconfigure.SmsAutoConfiguration
 org.dromara.maxkey.autoconfigure.SessionAutoConfiguration
 org.dromara.maxkey.autoconfigure.TokenAutoConfiguration