dongyukun
8 天以前 6eeac9efdb16f92d19536bf23a2d1471705fe752
提交 | 用户 | 时间
a6de49 1 package com.iailab;
H 2
c12dae 3 import com.iailab.module.model.mpk.common.MdkConstant;
D 4 import com.iailab.module.model.mpk.common.utils.DllUtils;
912a1e 5 import iail.mdk.model.common.Environment;
c12dae 6 import lombok.extern.slf4j.Slf4j;
D 7 import org.springframework.beans.factory.annotation.Value;
a6de49 8 import org.springframework.boot.CommandLineRunner;
H 9 import org.springframework.boot.SpringApplication;
10 import org.springframework.boot.autoconfigure.SpringBootApplication;
6eeac9 11 import org.springframework.context.annotation.ComponentScan;
7fd198 12 import org.springframework.scheduling.annotation.EnableAsync;
a6de49 13
c12dae 14 import javax.annotation.PostConstruct;
912a1e 15 import java.io.File;
D 16 import java.io.InputStream;
7fd198 17 import java.util.Properties;
18
19 @EnableAsync
a6de49 20 @SpringBootApplication
c12dae 21 @Slf4j
a6de49 22 public class ModelServiceApplication implements CommandLineRunner {
H 23
c12dae 24     @Value("${mpk.bak-file-path}")
D 25     private String mpkBakFilePath;
26
27     @PostConstruct
28     void init() {
7fd198 29         //加载动态链接库
30         try {
31             Properties properties = new Properties();
912a1e 32             InputStream in = ModelServiceApplication.class.getClassLoader().getResourceAsStream("iailmdk.properties");
D 33             properties.load(in);
34             String mdkInitPath = properties.getProperty("mdk-init-path");
c12dae 35             log.info("mdkInitPath=" + mdkInitPath);
912a1e 36             File file = new File(mdkInitPath + File.separator + "IAIL.MDK.Mid.Windows.dll");
D 37             if (!file.exists()) {
38                 throw new RuntimeException("动态链接库IAIL.MDK.Mid.Windows.dll文件不存在," + file.getAbsolutePath());
39             }
40             System.load(file.getAbsolutePath());
41             Environment env = new Environment();
42             env.init();
7fd198 43         } catch (Exception e) {
44             e.printStackTrace();
c12dae 45             log.error("动态链接库IAIL.MDK.Mid.Windows.dll初始化失败");
7fd198 46         }
449017 47
c12dae 48         //加载项目已发布的dll和jar
D 49         try {
558ffc 50             log.info("************开始加载项目已发布的dll和jar**************");
c12dae 51             DllUtils.loadProjectPublish(mpkBakFilePath + File.separator + MdkConstant.PROJECT_PUBLISH);
558ffc 52             log.info("************加载项目已发布的dll和jar结束**************");
c12dae 53         } catch (Exception e) {
D 54             e.printStackTrace();
55             log.error("加载项目已发布的dll和jar失败");
56         }
7fd198 57     }
137356 58
a6de49 59
H 60     public static void main(String[] args) {
61         SpringApplication.run(ModelServiceApplication.class, args);
62     }
63
64     /**
65      * 容器初始化后加载路由
66      *
67      * @param strings
68      */
69     @Override
70     public void run(String... strings) {
71     }
72 }