You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
two_project/src/main/java/com/mathgenerator/service/EmailConfig.java

35 lines
1003 B

package com.mathgenerator.service;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class EmailConfig {
private static final Properties properties = new Properties();
static {
try (InputStream input = new FileInputStream("config.properties")) {
properties.load(input);
} catch (IOException ex) {
System.err.println("错误:无法加载 config.properties 文件!请确保该文件在项目根目录中。");
ex.printStackTrace();
}
}
public static String getHost() {
return properties.getProperty("smtp.host");
}
public static int getPort() {
return Integer.parseInt(properties.getProperty("smtp.port"));
}
public static String getUsername() {
return properties.getProperty("smtp.username");
}
public static String getPassword() {
return properties.getProperty("smtp.password");
}
}