Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ConfigYml.java #43

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update ConfigYml.java
解决以jar包形式运行时找不到“application.yml”文件的问题。
  • Loading branch information
CoolGeo2016 committed Sep 20, 2018
commit a5e72b7eab9a120b658fa6a8e0c31e1af71007c3
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down