|
@@ -1,6 +1,5 @@
|
|
|
package com.qmth.cqb;
|
|
|
|
|
|
-import com.qmth.cqb.utils.GridFSUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
@@ -15,6 +14,8 @@ import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
|
|
|
|
+import com.qmth.cqb.utils.GridFSUtil;
|
|
|
+
|
|
|
/**
|
|
|
* 项目入口主程序
|
|
|
*
|
|
@@ -22,39 +23,42 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
|
|
|
@SpringBootApplication
|
|
|
@EnableEurekaClient
|
|
|
@EnableFeignClients
|
|
|
-@EnableAutoConfiguration(exclude = {MultipartAutoConfiguration.class})
|
|
|
+@EnableAutoConfiguration(exclude = { MultipartAutoConfiguration.class })
|
|
|
public class App {
|
|
|
|
|
|
@Autowired
|
|
|
GridFSUtil gridFSUtil;
|
|
|
|
|
|
- public static void main(String[] args){
|
|
|
+ public static void main(String[] args) {
|
|
|
SpringApplication.run(App.class, args);
|
|
|
}
|
|
|
|
|
|
- //显示声明CommonsMultipartResolver为mutipartResolver
|
|
|
+ // 显示声明CommonsMultipartResolver为mutipartResolver
|
|
|
@Bean(name = "multipartResolver")
|
|
|
- public MultipartResolver multipartResolver(){
|
|
|
+ public MultipartResolver multipartResolver() {
|
|
|
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
|
|
|
resolver.setDefaultEncoding("UTF-8");
|
|
|
- resolver.setResolveLazily(true);//resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常
|
|
|
+ resolver.setResolveLazily(true);// resolveLazily属性启用是为了推迟文件解析,以在在UploadAction中捕获文件大小异常
|
|
|
resolver.setMaxInMemorySize(40960);
|
|
|
- resolver.setMaxUploadSize(200*1024*1024);//上传文件大小 50M 50*1024*1024
|
|
|
+ resolver.setMaxUploadSize(200 * 1024 * 1024);// 上传文件大小 50M 50*1024*1024
|
|
|
return resolver;
|
|
|
}
|
|
|
|
|
|
@Bean
|
|
|
public WebMvcConfigurer corsConfigurer() {
|
|
|
return new WebMvcConfigurerAdapter() {
|
|
|
+
|
|
|
public void addCorsMappings(CorsRegistry registry) {
|
|
|
registry.addMapping("/**");
|
|
|
|
|
|
-// registry.addMapping("/**")
|
|
|
-// .allowedOrigins("*")
|
|
|
-// .allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "TRACE")
|
|
|
-// .allowedHeaders("*")
|
|
|
-// .exposedHeaders("access_token", "credentials", "refresh_token")
|
|
|
-// .allowCredentials(true).maxAge(3600);
|
|
|
+ // registry.addMapping("/**")
|
|
|
+ // .allowedOrigins("*")
|
|
|
+ // .allowedMethods("GET", "HEAD", "POST", "PUT", "PATCH",
|
|
|
+ // "DELETE", "OPTIONS", "TRACE")
|
|
|
+ // .allowedHeaders("*")
|
|
|
+ // .exposedHeaders("access_token", "credentials",
|
|
|
+ // "refresh_token")
|
|
|
+ // .allowCredentials(true).maxAge(3600);
|
|
|
}
|
|
|
};
|
|
|
}
|