master
gaojie 2019-06-21 13:39:05 +08:00
parent 926c0d0414
commit d5b3253e8d
2 changed files with 9 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.io.FileInputStream;
import java.io.InputStream;
//创建的类名根据需要定义但一定要实现ServletContextListener接口
@ -23,11 +24,12 @@ public class WebContextListener implements ServletContextListener {
String osName = System.getProperty("os.name");
if (osName.matches("^(?i)Windows.*$")) {// Window 系统
path = DEFAULT_CONFIG_PATH;
inputStream = getClass().getResourceAsStream(path);
}else{
path += "/config/jl_loginserver/application.properties";
inputStream = new FileInputStream(path);
}
inputStream = getClass().getResourceAsStream(path);
LOGGER.info("WebContextListener==>path={}",path);
if (inputStream != null) {
BaseGlobal.getInstance().properties.load(inputStream);
}

View File

@ -27,8 +27,12 @@ public class RedisUtil {
config.setMaxWaitMillis(Integer.parseInt(properties.getProperty("redis_maxWaitMillis")));
config.setMaxIdle(Integer.parseInt(properties.getProperty("redis_maxIdle")));
config.setTestOnBorrow(Boolean.parseBoolean(properties.getProperty("redis_testOnBorrow")));
if (properties.getProperty("redis_password") ==null || properties.getProperty("redis_password").isEmpty()){
jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0);
}else{
jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0,properties.getProperty("redis_password"));
}
}
/***************************************普通键值对操作***************************************/
//设置键值