From 1e5f72d2d9cc1656fb54308faf29410ec8ed0b5a Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Thu, 10 Feb 2022 13:07:49 +0800 Subject: [PATCH] =?UTF-8?q?[manager]fix=E5=BC=80=E5=8F=91=E5=92=8C?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E7=8E=AF=E5=A2=83=E8=AF=BB=E5=8F=96=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E6=97=B6=E8=B7=AF=E5=BE=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/usthe/manager/service/impl/AppServiceImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java b/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java index 35528a8..3d7ec28 100644 --- a/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java +++ b/manager/src/main/java/com/usthe/manager/service/impl/AppServiceImpl.java @@ -123,12 +123,18 @@ public class AppServiceImpl implements AppService, CommandLineRunner { public void run(String... args) throws Exception { // 读取app定义配置加载到内存中 define/app/*.yml Yaml yaml = new Yaml(); - String classpath = this.getClass().getClassLoader().getResource("").getPath(); + String classpath = this.getClass().getResource(File.separator).getPath(); String defineAppPath = classpath + File.separator + "define" + File.separator + "app"; File directory = new File(defineAppPath); if (!directory.exists() || directory.listFiles() == null) { - throw new IllegalArgumentException("define app directory not exist: " + defineAppPath); + classpath = this.getClass().getResource("").getPath(); + defineAppPath = classpath + File.separator + "define" + File.separator + "app"; + directory = new File(defineAppPath); + if (!directory.exists() || directory.listFiles() == null) { + throw new IllegalArgumentException("define app directory not exist: " + defineAppPath); + } } + log.info("query define path {}", defineAppPath); for (File appFile : Objects.requireNonNull(directory.listFiles())) { if (appFile.exists()) { try (FileInputStream fileInputStream = new FileInputStream(appFile)) {