Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.

Commit be4751b

Browse files
committed
🔧 Add and optimize env variables
1 parent 8b58b9c commit be4751b

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
CLIPLT_DEBUG=TRUE
1+
CLIPLT_EMAIL_DEBUG=TRUE
2+
CLIPLT_CONFIG_PATH=C:\Users\scruel\Desktop\TOOL\auto\clipIt\config.properties";

src/main/java/pers/scruel/util/MailUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class MailUtils {
2727
* 初始化方法
2828
*/
2929
public MailUtils() throws GeneralSecurityException, IOException {
30-
boolean debug = Boolean.parseBoolean(System.getenv("CLIPLT_DEBUG"));
30+
boolean debug = Boolean.parseBoolean(System.getenv("CLIPLT_EMAIL_DEBUG"));
3131
System.setProperty("mail.mime.splitlongparameters", "false");
3232
Properties properties = PropertiesUtils.getProperties();
3333
this.mailHost = properties.getProperty("stk.mail.smtp.host");

src/main/java/pers/scruel/util/PropertiesUtils.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@
1212
*/
1313
public class PropertiesUtils {
1414
private static final Properties PROPERTIES = new Properties();
15-
private static final String SCRUEL_TEST_PATH = "C:\\Users\\scruel\\Desktop\\TOOL\\auto\\clipIt\\config.properties";
1615
private static boolean loaded = false;
1716

1817
public static Properties getProperties() throws IOException {
1918
if (loaded) {
2019
return PROPERTIES;
2120
}
22-
if (Boolean.parseBoolean(System.getenv("CLIPLT_DEBUG"))) {
23-
PROPERTIES.load(Files.newInputStream(Paths.get(SCRUEL_TEST_PATH)));
24-
}
25-
else {
26-
PROPERTIES.load(Files.newInputStream(Paths.get("config.properties")));
21+
String configPath = System.getenv("CLIPLT_CONFIG_PATH");
22+
if (null == configPath) {
23+
configPath = "config.properties";
2724
}
25+
PROPERTIES.load(Files.newInputStream(Paths.get(configPath)));
2826
loaded = true;
2927
return PROPERTIES;
3028
}

0 commit comments

Comments
 (0)