From eb02fe632e70128f3a0635d46c12d4dc8f6ef2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=A8=E6=9C=A8c?= <857448963@qq.com> Date: Fri, 18 Aug 2023 11:16:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E7=BA=A7=E7=AE=97=E6=B3=95=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/advance/utils/JnaCallDllOrSo.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) 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 9f588faf1..c2e9eaf3e 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 @@ -2,6 +2,7 @@ package com.njcn.advance.utils; import cn.hutool.core.io.resource.ClassPathResource; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.io.FileUtils; import java.io.*; import java.net.URLDecoder; @@ -25,33 +26,30 @@ public class JnaCallDllOrSo { String os = System.getProperty("os.name"); // windows操作系统为1 否则为0 int beginIndex = os != null && os.startsWith("Windows") ? 1 : 0; - if(beginIndex == 0){ + if (beginIndex == 0) { //linux操作系统 - this.nameDll = "lib"+name+"_dll.so"; + this.nameDll = "lib" + name + "_dll.so"; - String resource = Thread.currentThread().getContextClassLoader().getResource(this.nameDll).getPath(); - log.info(resource); - String path = new ClassPathResource(this.nameDll).getClassLoader().getResource(this.nameDll).getPath(); - log.info(path); - this.path = path; + + + this.path = "/usr/local/jarfiles/advanceboot/BOOT-INF/classes/"+this.nameDll; //this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"); - }else { - this.nameDll = name+".dll"; + } else { + this.nameDll = name + ".dll"; this.path = URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().replaceFirst("/", ""), "UTF-8"); } } catch (UnsupportedEncodingException e) { log.error(e.getMessage()); } - if (JnaCallDllOrSo.jarPath.equals("")) { + /* if (JnaCallDllOrSo.jarPath.equals("")) { JnaCallDllOrSo.jarPath = this.path.substring(0, this.path.lastIndexOf('/')); - } + }*/ } - public String getStrpath() { - String aa = this.path+this.nameDll; + String aa = this.path + this.nameDll; return aa.replace("/", File.separator); }