diff --git a/pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/WaveUtils.java b/pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/WaveUtils.java index 3d971800a..680c8f3bc 100644 --- a/pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/WaveUtils.java +++ b/pqs-advance/advance-api/src/main/java/com/njcn/advance/utils/WaveUtils.java @@ -2,7 +2,6 @@ package com.njcn.advance.utils; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.CharsetUtil; -import com.njcn.event.api.RmpEventDetailFeignClient; import com.njcn.oss.utils.FileStorageUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java index 4458f0173..a9d252e49 100644 --- a/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java +++ b/pqs-advance/advance-boot/src/main/java/com/njcn/advance/utils/JnaCallDllOrSo.java @@ -22,35 +22,48 @@ public class JnaCallDllOrSo { public JnaCallDllOrSo(String name) { super(); + String suffix = ".dll"; try { String os = System.getProperty("os.name"); // windows操作系统为1 否则为0 int beginIndex = os != null && os.startsWith("Windows") ? 1 : 0; if (beginIndex == 0) { //linux操作系统 - this.nameDll = "lib" + name + "_dll.so"; - - - - this.path = "/usr/local/jarfiles/advanceboot/BOOT-INF/classes/"; + this.nameDll = "lib" + name + "_dll"; + suffix = ".so"; +// this.path = "/usr/local/jarfiles/advanceboot/BOOT-INF/classes/"; //this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"); } else { - this.nameDll = name + ".dll"; - this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replaceFirst("/", ""), "UTF-8"); + this.nameDll = name; +// this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replaceFirst("/", ""), "UTF-8"); } - } catch (UnsupportedEncodingException e) { + File tempFile; + try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(this.nameDll.concat(suffix))) { + tempFile = File.createTempFile(this.nameDll, suffix); + try (FileOutputStream outputStream = new FileOutputStream(tempFile)) { + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + } + } + this.path = tempFile.getAbsolutePath(); + System.out.println(1); + System.out.println(1); + } catch (Exception e) { log.error(e.getMessage()); } - /* if (JnaCallDllOrSo.jarPath.equals("")) { - JnaCallDllOrSo.jarPath = this.path.substring(0, this.path.lastIndexOf('/')); - }*/ + + } public String getStrpath() { - String aa = this.path + this.nameDll; - return aa.replace("/", File.separator); + return this.path; +// String aa = this.path + this.nameDll; +// return aa.replace("/", File.separator); } public void setPath() {