YueMumApplication.java 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package com.ygj.yuemum;
  2. import com.github.pagehelper.PageHelper;
  3. import org.mybatis.spring.annotation.MapperScan;
  4. import org.springframework.boot.SpringApplication;
  5. import org.springframework.boot.autoconfigure.SpringBootApplication;
  6. import org.springframework.boot.builder.SpringApplicationBuilder;
  7. import org.springframework.boot.web.servlet.MultipartConfigFactory;
  8. import org.springframework.boot.web.support.SpringBootServletInitializer;
  9. import org.springframework.context.annotation.Bean;
  10. import org.springframework.scheduling.annotation.EnableScheduling;
  11. import org.springframework.web.WebApplicationInitializer;
  12. import javax.servlet.MultipartConfigElement;
  13. import java.util.Properties;
  14. @SpringBootApplication
  15. @MapperScan("com.ygj.yuemum.dao")
  16. @EnableScheduling
  17. public class YueMumApplication {
  18. public static void main(String[] args) {
  19. SpringApplication.run(YueMumApplication.class, args);
  20. }
  21. @Bean
  22. public PageHelper pageHelper() {
  23. PageHelper pageHelper = new PageHelper();
  24. Properties properties = new Properties();
  25. properties.setProperty("offsetAsPageNum", "true");
  26. properties.setProperty("rowBoundsWithCount", "true");
  27. properties.setProperty("reasonable", "true");
  28. properties.setProperty("dialect", "mysql"); //配置mysql数据库的方言
  29. pageHelper.setProperties(properties);
  30. return pageHelper;
  31. }
  32. @Bean
  33. public MultipartConfigElement multipartConfigElement() {
  34. MultipartConfigFactory factory = new MultipartConfigFactory();
  35. // 单个数据大小
  36. factory.setMaxFileSize("50240KB");
  37. /// 总上传数据大小
  38. factory.setMaxRequestSize("50240KB");
  39. return factory.createMultipartConfig();
  40. }
  41. }
  42. //public class YueMumApplication extends SpringBootServletInitializer implements WebApplicationInitializer {
  43. //
  44. // @Override
  45. // protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
  46. //
  47. // return application.sources(YueMumApplication.class);
  48. // }
  49. //
  50. // public static void main(String[] args) {
  51. // SpringApplication.run(YueMumApplication.class, args);
  52. // }
  53. // @Bean
  54. // public PageHelper pageHelper() {
  55. // PageHelper pageHelper = new PageHelper();
  56. // Properties properties = new Properties();
  57. // properties.setProperty("offsetAsPageNum", "true");
  58. // properties.setProperty("rowBoundsWithCount", "true");
  59. // properties.setProperty("reasonable", "true");
  60. // properties.setProperty("dialect", "mysql"); //配置mysql数据库的方言
  61. // pageHelper.setProperties(properties);
  62. // return pageHelper;
  63. // }
  64. // @Bean
  65. // public MultipartConfigElement multipartConfigElement() {
  66. // MultipartConfigFactory factory = new MultipartConfigFactory();
  67. // // 单个数据大小
  68. // factory.setMaxFileSize("10240KB");
  69. // /// 总上传数据大小
  70. // factory.setMaxRequestSize("10240KB");
  71. // return factory.createMultipartConfig();
  72. // }
  73. //}