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