对比新文件 |
| | |
| | | package com.gk.firework.Config.Cors; |
| | | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.config.annotation.CorsRegistry; |
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | |
| | | @Configuration |
| | | public class MyMvcConfigurer implements WebMvcConfigurer { |
| | | @Value("${filePath}") |
| | | private String filePath; //配置文件配置的物理保存地址 |
| | | @Value("${sqlPath}") |
| | | private String sqlPath; |
| | | @Value("${enterprisePath}") |
| | | private String enterprisePath; //配置文件配置的物理保存地址 |
| | | @Value("${contractPath}") |
| | | private String contractPath; //配置文件配置的物理保存地址 |
| | | @Value("${transportCertificatePath}") |
| | | private String transportCertificatePath; |
| | | @Value("${hiddenDangerPath}") |
| | | private String hiddenDangerPath; |
| | | @Value("${patrolPath}") |
| | | private String patrolPath; |
| | | @Value("${appPath}") |
| | | private String appPath; |
| | | @Value("${customerPath}") |
| | | private String customerPath; |
| | | |
| | | @Override |
| | | public void addCorsMappings(CorsRegistry registry) { |
| | | registry.addMapping("/**") |
| | | .allowedOrigins("*") |
| | | .allowCredentials(true) |
| | | .allowedMethods("GET", "POST", "DELETE", "PUT","PATCH") |
| | | .maxAge(3600); |
| | | } |
| | | |
| | | /**服务器静态资源配置**/ |
| | | @Override |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) { |
| | | registry.addResourceHandler("/upload/**") |
| | | .addResourceLocations("file:"+ filePath) //媒体资源 |
| | | .addResourceLocations("classpath:/META-INF/resources/"); //swagger2页面 |
| | | registry.addResourceHandler("/dbback/**") |
| | | .addResourceLocations("file:"+sqlPath); |
| | | registry.addResourceHandler("/upload/enterprise/**") |
| | | .addResourceLocations("file:"+enterprisePath); |
| | | registry.addResourceHandler("/upload/contract/**") |
| | | .addResourceLocations("file:"+contractPath); |
| | | registry.addResourceHandler("/upload/transportCertificate/**") |
| | | .addResourceLocations("file:" + transportCertificatePath); |
| | | registry.addResourceHandler("/upload/hiddenDanger/**") |
| | | .addResourceLocations("file:" + hiddenDangerPath); |
| | | registry.addResourceHandler("/upload/patrol/**") |
| | | .addResourceLocations("file:" + patrolPath); |
| | | registry.addResourceHandler("/upload/app/**") |
| | | .addResourceLocations("file:" + appPath); |
| | | registry.addResourceHandler("/upload/customer/**") |
| | | .addResourceLocations("file:" + customerPath); |
| | | registry.addResourceHandler("/logs/**"). |
| | | addResourceLocations("file:" + System.getProperty("user.dir") + "/logs/"); |
| | | |
| | | } |
| | | } |