配置文件

master
gaojie 2019-06-21 10:07:35 +08:00
parent e84516cd73
commit f8b04b9b89
3 changed files with 7 additions and 3 deletions

View File

@ -11,7 +11,7 @@ import java.io.InputStream;
//创建的类名根据需要定义但一定要实现ServletContextListener接口
public class WebContextListener implements ServletContextListener {
private static final Logger LOGGER = LoggerFactory.getLogger(ServletContextListener.class);
private static final String DEFAULT_CONFIG_PATH = "/application.properties";
private static String DEFAULT_CONFIG_PATH = "/application.properties";
@Override
public void contextInitialized(ServletContextEvent arg0) {
@ -19,6 +19,10 @@ public class WebContextListener implements ServletContextListener {
LOGGER.debug("dddddddddddddddddddddddddddddddd");
InputStream inputStream = null;
try {
String osName = System.getProperty("os.name");
if (!osName.matches("^(?i)Windows.*$")) {// Linux 系统
DEFAULT_CONFIG_PATH = "../conf/application.properties";
}
inputStream = getClass().getResourceAsStream(DEFAULT_CONFIG_PATH);
if (inputStream != null) {
BaseGlobal.getInstance().properties.load(inputStream);

View File

@ -27,7 +27,7 @@ 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")));
jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0,properties.getProperty("jieling666"));
jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0,properties.getProperty("redis_password"));
}
/***************************************普通键值对操作***************************************/

View File

@ -25,7 +25,7 @@ public class MyMongoDBPool {
buide.maxConnectionLifeTime(Integer.parseInt(properties.getProperty("mongodb_maxConnectionLifeTime")));
buide.socketTimeout(Integer.parseInt(properties.getProperty("mongodb_socketTimeout")));
buide.socketKeepAlive(Boolean.parseBoolean(properties.getProperty("mongodb_socketKeepAlive")));
MongoClientURI mongodb_host = new MongoClientURI(properties.getProperty("mongodb_host"),buide);
MongoClientURI mongodb_host = new MongoClientURI(properties.getProperty("mongodb_url"),buide);
mongoClient = new MongoClient(mongodb_host);
dbName = properties.getProperty("mongodb_name");
db = mongoClient.getDB(dbName);