IppIdpApplication.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.jiayue.ipp.idp;
  2. import org.apache.velocity.app.Velocity;
  3. import org.apache.velocity.app.VelocityEngine;
  4. import org.springframework.boot.SpringApplication;
  5. import org.springframework.boot.autoconfigure.SpringBootApplication;
  6. import org.springframework.context.annotation.Bean;
  7. import org.springframework.scheduling.TaskScheduler;
  8. import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
  9. import java.util.Properties;
  10. @SpringBootApplication
  11. public class IppIdpApplication {
  12. public static void main(String[] args) {
  13. SpringApplication.run(IppIdpApplication.class, args);
  14. }
  15. /**
  16. * 上报文件模板引擎
  17. *
  18. * @return 返回模板引擎
  19. */
  20. @Bean
  21. public VelocityEngine velocityEngine() {
  22. VelocityEngine ve = new VelocityEngine();
  23. Properties properties = new Properties();
  24. //设置velocity资源加载方式为file
  25. properties.setProperty("resource.loader", "file");
  26. //设置velocity资源加载方式为file时的处理类
  27. properties
  28. .setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
  29. properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "");
  30. properties.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
  31. properties.setProperty(Velocity.INPUT_ENCODING, "UTF-8");
  32. properties.setProperty(Velocity.OUTPUT_ENCODING, "UTF-8");
  33. ve.init(properties);
  34. return ve;
  35. }
  36. @Bean
  37. public TaskScheduler taskScheduler(){
  38. ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
  39. // 线程池大小
  40. taskScheduler.setPoolSize(100);
  41. // 线程名字的前缀
  42. taskScheduler.setThreadNamePrefix("taskScheduler");
  43. return taskScheduler;
  44. }
  45. }