From a5e72b7eab9a120b658fa6a8e0c31e1af71007c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=B8=A8=E0=B9=89=E0=B9=89=E0=B9=89=E0=B9=89=E0=B9=89?= =?UTF-8?q?=E0=B9=89=E0=B9=89=E0=B9=89=E0=B9=89GIS=26DOTA=E0=B8=A8?= =?UTF-8?q?=E0=B9=89=E0=B9=89=E0=B9=89=E0=B9=89=E0=B9=89=E0=B9=89=E0=B9=89?= =?UTF-8?q?=E0=B9=89=E0=B9=89?= Date: Thu, 20 Sep 2018 09:42:43 +0800 Subject: [PATCH] Update ConfigYml.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决以jar包形式运行时找不到“application.yml”文件的问题。 --- .../main/java/apijson/demo/server/config/ConfigYml.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/APIJSON-Java-Server/APIJSONDemo_oracle/src/main/java/apijson/demo/server/config/ConfigYml.java b/APIJSON-Java-Server/APIJSONDemo_oracle/src/main/java/apijson/demo/server/config/ConfigYml.java index 9ca0b82ae..ff5576bb2 100644 --- a/APIJSON-Java-Server/APIJSONDemo_oracle/src/main/java/apijson/demo/server/config/ConfigYml.java +++ b/APIJSON-Java-Server/APIJSONDemo_oracle/src/main/java/apijson/demo/server/config/ConfigYml.java @@ -2,8 +2,8 @@ import org.ho.yaml.Yaml; -import java.io.File; import java.io.FileNotFoundException; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; @@ -13,9 +13,8 @@ * @description */ public class ConfigYml { - public Map read() { - String fileName = this.getClass().getClassLoader().getResource("application.yml").getPath();//获取文件路径 - File dumpFile=new File(fileName); + public Map read() { + InputStream dumpFile = this.getClass().getClassLoader().getResourceAsStream("application.yml"); Map father = null; try { father = Yaml.loadType(dumpFile, HashMap.class);