private SqlSessionFactory getSqlSessionFactory(String environment, String configFile) {
        Map<String, SqlSessionFactory> tempSqlSessionFactoryMap = FACTORY_MAP;
        if (!tempSqlSessionFactoryMap.containsKey(environment)) {
            synchronized (LOCK) {
                if (!tempSqlSessionFactoryMap.containsKey(environment)) {
                    try {
                        long start = System.currentTimeMillis();
                        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
                        reader = Resources.getResourceAsReader(configFile);
                        SqlSessionFactory factory = builder.build(reader, environment);
                        tempSqlSessionFactoryMap.put(environment, factory);
                        long end = System.currentTimeMillis();
                        if (end - start > 1000) {
                            LOGGER.warn(String.format("build datasource %s cost %d ms", environment, (end - start)));
                        }
                        return factory;
                    } catch (Exception e) {
                        LOGGER.error("Get SqlSessionFactory by environment {} error!Casue:{}", environment, e.getMessage());
                        return null;
                    } finally {
                        try {
                            reader.close();
                        } catch (IOException e) {
                            LOGGER.error(e.getMessage());
                        }
                    }
                }
            }
        }
        return tempSqlSessionFactoryMap.get(environment);
    }