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

View File

@ -27,7 +27,11 @@ public class RedisUtil {
config.setMaxWaitMillis(Integer.parseInt(properties.getProperty("redis_maxWaitMillis"))); config.setMaxWaitMillis(Integer.parseInt(properties.getProperty("redis_maxWaitMillis")));
config.setMaxIdle(Integer.parseInt(properties.getProperty("redis_maxIdle"))); config.setMaxIdle(Integer.parseInt(properties.getProperty("redis_maxIdle")));
config.setTestOnBorrow(Boolean.parseBoolean(properties.getProperty("redis_testOnBorrow"))); config.setTestOnBorrow(Boolean.parseBoolean(properties.getProperty("redis_testOnBorrow")));
jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0,properties.getProperty("redis_password")); 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"));
}
} }
/***************************************普通键值对操作***************************************/ /***************************************普通键值对操作***************************************/