parent
dbf51a03ba
commit
18991c3f5b
@ -0,0 +1,81 @@
|
||||
package com.xxl.job.admin.core.conf;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* xxl-job config
|
||||
*
|
||||
* @author xuxueli 2017-04-28
|
||||
*/
|
||||
@Configuration
|
||||
public class XxlJobAdminConfig implements InitializingBean{
|
||||
private static XxlJobAdminConfig adminConfig = null;
|
||||
public static XxlJobAdminConfig getAdminConfig() {
|
||||
return adminConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
adminConfig = this;
|
||||
}
|
||||
|
||||
@Value("${xxl.job.mail.host}")
|
||||
private String mailHost;
|
||||
|
||||
@Value("${xxl.job.mail.port}")
|
||||
private String mailPort;
|
||||
|
||||
@Value("${xxl.job.mail.username}")
|
||||
private String mailUsername;
|
||||
|
||||
@Value("${xxl.job.mail.password}")
|
||||
private String mailPassword;
|
||||
|
||||
@Value("${xxl.job.mail.sendNick}")
|
||||
private String mailSendNick;
|
||||
|
||||
@Value("${xxl.job.login.username}")
|
||||
private String loginUsername;
|
||||
|
||||
@Value("${xxl.job.login.password}")
|
||||
private String loginPassword;
|
||||
|
||||
@Value("${xxl.job.i18n}")
|
||||
private String i18n;
|
||||
|
||||
|
||||
public String getMailHost() {
|
||||
return mailHost;
|
||||
}
|
||||
|
||||
public String getMailPort() {
|
||||
return mailPort;
|
||||
}
|
||||
|
||||
public String getMailUsername() {
|
||||
return mailUsername;
|
||||
}
|
||||
|
||||
public String getMailPassword() {
|
||||
return mailPassword;
|
||||
}
|
||||
|
||||
public String getMailSendNick() {
|
||||
return mailSendNick;
|
||||
}
|
||||
|
||||
public String getLoginUsername() {
|
||||
return loginUsername;
|
||||
}
|
||||
|
||||
public String getLoginPassword() {
|
||||
return loginPassword;
|
||||
}
|
||||
|
||||
public String getI18n() {
|
||||
return i18n;
|
||||
}
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.xxl.job.admin.core.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.EncodedResource;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* properties util
|
||||
*
|
||||
* @author xuxueli 2015-8-28 10:35:53
|
||||
*/
|
||||
public class PropertiesUtil {
|
||||
private static Logger logger = LoggerFactory.getLogger(PropertiesUtil.class);
|
||||
private static final String file_name = "xxl-job-admin.properties";
|
||||
|
||||
|
||||
public static String getString(String key) {
|
||||
Properties prop = null;
|
||||
try {
|
||||
Resource resource = new ClassPathResource(file_name);
|
||||
EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
|
||||
prop = PropertiesLoaderUtils.loadProperties(encodedResource);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
if (prop!=null) {
|
||||
return prop.getProperty(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package com.xxl.job.admin.util;
|
||||
|
||||
import com.xxl.job.admin.core.util.PropertiesUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* prop util test
|
||||
*
|
||||
* @author xuxueli 2017-12-25 15:17:36
|
||||
*/
|
||||
public class PropertiesUtilTest {
|
||||
|
||||
@Test
|
||||
public void registryTest() throws Exception {
|
||||
System.out.println(PropertiesUtil.getString("xxl.job.login.username"));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue