|
@@ -0,0 +1,55 @@
|
|
|
+package cn.com.qmth.examcloud.exchange.starter;
|
|
|
+
|
|
|
+import org.slf4j.MDC;
|
|
|
+import org.springframework.boot.SpringApplication;
|
|
|
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
|
+import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
+import org.springframework.boot.autoconfigure.domain.EntityScan;
|
|
|
+import org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration;
|
|
|
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|
|
+import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
|
|
+import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.ComponentScan;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+import org.springframework.web.multipart.MultipartResolver;
|
|
|
+import org.springframework.web.multipart.commons.CommonsMultipartResolver;
|
|
|
+
|
|
|
+import cn.com.qmth.examcloud.common.support.logging.ExamCloudLog;
|
|
|
+import cn.com.qmth.examcloud.common.support.logging.ExamCloudLogFactory;
|
|
|
+import cn.com.qmth.examcloud.common.support.logging.SLF4JImpl;
|
|
|
+
|
|
|
+@ComponentScan(basePackages = { "com.qmth.commons", "cn.com.qmth" })
|
|
|
+@EntityScan(basePackages = { "com.qmth.commons", "cn.com.qmth" })
|
|
|
+@SpringBootApplication
|
|
|
+@EnableEurekaClient
|
|
|
+@EnableDiscoveryClient
|
|
|
+@EnableAutoConfiguration(exclude = { MultipartAutoConfiguration.class })
|
|
|
+public class ExchangeApplication {
|
|
|
+
|
|
|
+ private static final ExamCloudLog LOG = ExamCloudLogFactory.getLog(ExchangeApplication.class);
|
|
|
+
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
+
|
|
|
+ if (LOG instanceof SLF4JImpl) {
|
|
|
+ MDC.put("TRACE_ID", Thread.currentThread().getName());
|
|
|
+ }
|
|
|
+ SpringApplication.run(ExchangeApplication.class, args);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ @LoadBalanced
|
|
|
+ public RestTemplate restTemplate() {
|
|
|
+ return new RestTemplate();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean(name = "multipartResolver")
|
|
|
+ public MultipartResolver multipartResolver() {
|
|
|
+ CommonsMultipartResolver resolver = new CommonsMultipartResolver();
|
|
|
+ resolver.setDefaultEncoding("UTF-8");
|
|
|
+ resolver.setResolveLazily(true);
|
|
|
+ resolver.setMaxInMemorySize(40960);
|
|
|
+ resolver.setMaxUploadSize(200 * 1024 * 1024);
|
|
|
+ return resolver;
|
|
|
+ }
|
|
|
+}
|