diff --git a/maxkey-core/src/main/java/org/dromara/maxkey/autoconfigure/ResourceMvcConfig.java b/maxkey-core/src/main/java/org/dromara/maxkey/autoconfigure/ResourceMvcConfig.java new file mode 100644 index 000000000..f74099fe1 --- /dev/null +++ b/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 ."); + } +} diff --git a/maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMvcConfig.java b/maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMvcConfig.java index fad2f9e39..271b72b87 100644 --- a/maxkey-webs/maxkey-web-maxkey/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMvcConfig.java +++ b/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) { diff --git a/maxkey-webs/maxkey-web-maxkey/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/maxkey-webs/maxkey-web-maxkey/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 647c9e993..285503981 100644 --- a/maxkey-webs/maxkey-web-maxkey/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/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 diff --git a/maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMgtMvcConfig.java b/maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMgtMvcConfig.java index a02e7765d..129cacf7a 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyMgtMvcConfig.java +++ b/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) { diff --git a/maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 2e3653845..b5d4d7b8b 100644 --- a/maxkey-webs/maxkey-web-mgt/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/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 diff --git a/maxkey-webs/maxkey-web-openapi/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyOpenApiMvcConfig.java b/maxkey-webs/maxkey-web-openapi/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyOpenApiMvcConfig.java index 14ef87d95..c61bb9c3d 100644 --- a/maxkey-webs/maxkey-web-openapi/src/main/java/org/dromara/maxkey/autoconfigure/MaxKeyOpenApiMvcConfig.java +++ b/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) { diff --git a/maxkey-webs/maxkey-web-openapi/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/maxkey-webs/maxkey-web-openapi/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 25f58d023..99366cedd 100644 --- a/maxkey-webs/maxkey-web-openapi/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/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