AppConfig

This commit is contained in:
redkale
2024-08-15 12:06:07 +08:00
parent 8c0b9a0f6a
commit c520910d5c

View File

@@ -420,12 +420,9 @@ class AppConfig {
confDir = f.getParentFile().getCanonicalPath(); confDir = f.getParentFile().getCanonicalPath();
} else { } else {
f = new File(confDir, "application.yml"); f = new File(confDir, "application.yml");
if (f.isFile() && f.canRead()) { if (!f.isFile() || !f.canRead()) {
appConfFile = f.toURI();
confDir = f.getParentFile().getCanonicalPath();
yaml = true;
} else {
f = new File(confDir, "application.yaml"); f = new File(confDir, "application.yaml");
}
if (f.isFile() && f.canRead()) { if (f.isFile() && f.canRead()) {
appConfFile = f.toURI(); appConfFile = f.toURI();
confDir = f.getParentFile().getCanonicalPath(); confDir = f.getParentFile().getCanonicalPath();
@@ -466,7 +463,6 @@ class AppConfig {
} }
} }
} }
}
} else { // 相对路径 } else { // 相对路径
File f = new File(new File(home, confDir), "application.xml"); File f = new File(new File(home, confDir), "application.xml");
if (f.isFile() && f.canRead()) { if (f.isFile() && f.canRead()) {
@@ -474,12 +470,9 @@ class AppConfig {
confDir = f.getParentFile().getCanonicalPath(); confDir = f.getParentFile().getCanonicalPath();
} else { } else {
f = new File(new File(home, confDir), "application.yml"); f = new File(new File(home, confDir), "application.yml");
if (f.isFile() && f.canRead()) { if (!f.isFile() || !f.canRead()) {
appConfFile = f.toURI(); f = new File(confDir, "application.yaml");
confDir = f.getParentFile().getCanonicalPath(); }
yaml = true;
} else {
f = new File(new File(home, confDir), "application.yaml");
if (f.isFile() && f.canRead()) { if (f.isFile() && f.canRead()) {
appConfFile = f.toURI(); appConfFile = f.toURI();
confDir = f.getParentFile().getCanonicalPath(); confDir = f.getParentFile().getCanonicalPath();
@@ -521,7 +514,6 @@ class AppConfig {
} }
} }
} }
}
System.setProperty(RESNAME_APP_CONF_DIR, confDir); System.setProperty(RESNAME_APP_CONF_DIR, confDir);
String text = Utility.readThenClose(appConfFile.toURL().openStream()); String text = Utility.readThenClose(appConfFile.toURL().openStream());
AnyValue conf; AnyValue conf;