package com.xcong.farmer.cms.configurations; import com.xcong.farmer.cms.common.contants.AppContants; import com.xcong.farmer.cms.configurations.properties.ApplicationProperties; import com.xcong.farmer.cms.utils.SpringContextHolder; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringBootConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @author wzy * @date 2020-04-27 11:54 **/ @Slf4j @SpringBootConfiguration public class WebMvcConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { } /** * 设置cors跨域支持 * * @param registry */ @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") .allowedOrigins("*") .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS") .allowCredentials(true).maxAge(3600); } // @Bean // public SpringContextHolder springContextHolder() { // System.out.println(111111); // return new SpringContextHolder(); // } // @Value("${upload.file.location}") // private String fileLocation; // @Value("${upload.file.path}") // private String filePath; // @Override // public void addResourceHandlers(ResourceHandlerRegistry registry) { // //注册配置类,使用addResourceHandlers方法,将本地路径savePath映射到saveUrl路由上。 // registry.addResourceHandler(filePath).addResourceLocations(fileLocation); // WebMvcConfigurer.super.addResourceHandlers(registry); // } }