ApplicationInitialize.java 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package info.aspirecn.iov.sjjh.supplier10000027;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.apache.commons.io.FileUtils;
  4. import org.springframework.boot.ApplicationArguments;
  5. import org.springframework.boot.ApplicationRunner;
  6. import org.springframework.core.io.ClassPathResource;
  7. import org.springframework.stereotype.Component;
  8. import java.io.File;
  9. import java.io.InputStream;
  10. /**
  11. * @description:
  12. * @author: xusonglin
  13. * @create: 2019/10/24 15:52
  14. * @version: V1.0
  15. **/
  16. @Component
  17. @Slf4j
  18. public class ApplicationInitialize implements ApplicationRunner {
  19. @Override
  20. public void run(ApplicationArguments args) throws Exception {
  21. File bjcaRoot = new File("/usr/share/bjcaRoot");
  22. if(!bjcaRoot.exists()){
  23. bjcaRoot.mkdirs();
  24. }
  25. File bjcalog = new File("/usr/share/bjcaRoot/BJCAlog");
  26. if(!bjcalog.exists()){
  27. bjcalog.mkdirs();
  28. }
  29. File xtx = new File("/usr/share/bjcaRoot/BJCAlog/xtx");
  30. if(!xtx.exists()){
  31. xtx.mkdirs();
  32. }
  33. File xtxCoreSvr2 = new File("/usr/share/bjcaRoot/BJCAlog/XTXCoreSvr2");
  34. if(!xtxCoreSvr2.exists()){
  35. xtxCoreSvr2.mkdirs();
  36. }
  37. File bjcalogs = new File("/usr/share/bjcaRoot/logs");
  38. if(!bjcalogs.exists()){
  39. bjcalogs.mkdirs();
  40. }
  41. File xtxtradelog = new File("/usr/share/bjcaRoot/xtxtradelog");
  42. if(!xtxtradelog.exists()){
  43. xtxtradelog.mkdirs();
  44. }
  45. InputStream XTXAppCOM = new ClassPathResource("bjcaRoot/BJCAlog/xtx/XTXAppCOM.log").getInputStream();
  46. FileUtils.copyInputStreamToFile(XTXAppCOM,new File("/usr/share/bjcaRoot/BJCAlog/xtx/XTXAppCOM.log"));
  47. InputStream logxtxCoreSvr2 = new ClassPathResource("bjcaRoot/BJCAlog/XTXCoreSvr2/logXTXCoreSvr2.log").getInputStream();
  48. FileUtils.copyInputStreamToFile(logxtxCoreSvr2,new File("/usr/share/bjcaRoot/BJCAlog/XTXCoreSvr2/logXTXCoreSvr2.log"));
  49. InputStream svsError = new ClassPathResource("bjcaRoot/logs/SVSClient_error.log").getInputStream();
  50. FileUtils.copyInputStreamToFile(svsError,new File("/usr/share/bjcaRoot/logs/SVSClient_error.log"));
  51. InputStream svsSystem = new ClassPathResource("bjcaRoot/logs/SVSClient_system.log").getInputStream();
  52. FileUtils.copyInputStreamToFile(svsSystem,new File("/usr/share/bjcaRoot/logs/SVSClient_system.log"));
  53. InputStream bjcaConfig = new ClassPathResource("bjcaRoot/BJCA_Config.xml").getInputStream();
  54. FileUtils.copyInputStreamToFile(bjcaConfig,new File("/usr/share/bjcaRoot/BJCA_Config.xml"));
  55. InputStream properties = new ClassPathResource("bjcaRoot/SVSClient.properties").getInputStream();
  56. FileUtils.copyInputStreamToFile(properties,new File("/usr/share/bjcaRoot/SVSClient.properties"));
  57. log.info("文件夹已拷贝");
  58. }
  59. }