From f29346e0ef998e14f58025489cb87e285524d1fe Mon Sep 17 00:00:00 2001 From: "eunryong.hwang" Date: Wed, 20 Dec 2023 06:12:32 +0900 Subject: [PATCH] fix windows file path bug --- .../java/io/bastillion/common/util/AppConfig.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/bastillion/common/util/AppConfig.java b/src/main/java/io/bastillion/common/util/AppConfig.java index 59de5155..ca58ca44 100755 --- a/src/main/java/io/bastillion/common/util/AppConfig.java +++ b/src/main/java/io/bastillion/common/util/AppConfig.java @@ -15,8 +15,12 @@ import java.io.File; import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.FileSystems; +import java.nio.file.Paths; import java.security.GeneralSecurityException; import java.util.Map; +import java.util.Objects; import java.util.Set; /** @@ -26,9 +30,14 @@ public class AppConfig { private static final Logger log = LoggerFactory.getLogger(AppConfig.class); private static PropertiesConfiguration prop; - public static final String CONFIG_DIR = StringUtils.isNotEmpty(System.getProperty("CONFIG_DIR")) ? System.getProperty("CONFIG_DIR").trim() : AppConfig.class.getClassLoader().getResource(".").getPath(); + public static final String CONFIG_DIR; static { + try { + CONFIG_DIR = StringUtils.isNotEmpty(System.getProperty("CONFIG_DIR")) ? System.getProperty("CONFIG_DIR").trim() : Paths.get( Objects.requireNonNull(AppConfig.class.getClassLoader().getResource(".")).toURI()) + FileSystems.getDefault().getSeparator(); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } try { //move configuration to specified dir if (StringUtils.isNotEmpty(System.getProperty("CONFIG_DIR"))) {