ResourcesConfig.java 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.xtd.framework.config;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
  5. import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  6. import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
  7. import com.xtd.common.constant.Constants;
  8. import com.xtd.framework.interceptor.RepeatSubmitInterceptor;
  9. /**
  10. * 通用配置
  11. *
  12. * @author xtd
  13. */
  14. @Configuration
  15. public class ResourcesConfig implements WebMvcConfigurer
  16. {
  17. @Autowired
  18. private RepeatSubmitInterceptor repeatSubmitInterceptor;
  19. @Override
  20. public void addResourceHandlers(ResourceHandlerRegistry registry)
  21. {
  22. /** 本地文件上传路径 */
  23. registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
  24. /** swagger配置 */
  25. registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
  26. registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
  27. }
  28. /**
  29. * 自定义拦截规则
  30. */
  31. @Override
  32. public void addInterceptors(InterceptorRegistry registry)
  33. {
  34. registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
  35. }
  36. }