mirror of
https://github.com/dataease/dataease.git
synced 2026-05-24 06:18:10 +08:00
chore: 将资源的固定路径优化为可读取yml配置中的路径
This commit is contained in:
@@ -12,11 +12,13 @@ import java.util.Objects;
|
||||
*/
|
||||
public class ConfigUtils {
|
||||
|
||||
public static String configPath = "opt" + File.separator + "dataease2.0" + File.separator + "config" + File.separator + "application.yml";
|
||||
|
||||
public static String getConfig(String key, String defaultValue) {
|
||||
try {
|
||||
String filePath = System.getProperty("user.dir");
|
||||
filePath = filePath.replace("file:", "").substring(0, filePath.lastIndexOf("resources"));
|
||||
Resource resource = new FileSystemResource(filePath + "resources" + File.separator + "config" + File.separator + "application.yml");
|
||||
String filePath = System.getProperty("user.home");
|
||||
filePath = filePath.replace("file:", "");
|
||||
Resource resource = new FileSystemResource(filePath + File.separator + configPath);
|
||||
YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
|
||||
factory.setResources(resource);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user