package com.inkasso;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;
import org.springframework.web.client.RestTemplate;

import javax.servlet.MultipartConfigElement;

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableAsync
@EnableScheduling
public class ApplicationRun {

  public static void main(String[] args) {
    SpringApplication.run(ApplicationRun.class, args);
    System.out.println("========================启动成功============================");

  }

  @Bean
  public MultipartConfigElement multipartConfigElement() {
    DataSize maxFileSize = DataSize.of(100, DataUnit.MEGABYTES);
    DataSize maxRequestSize = DataSize.of(100, DataUnit.MEGABYTES);
    MultipartConfigFactory factory = new MultipartConfigFactory();
    factory.setMaxFileSize(maxFileSize);
    factory.setMaxRequestSize(maxRequestSize);
    return factory.createMultipartConfig();
  }

  @Bean
  public RestTemplate restTemplate(){

     return new RestTemplate();
  }
}
