org.springframework.core.io.support.PropertiesLoaderUtils#loadProperties ( )源码实例Demo

下面列出了org.springframework.core.io.support.PropertiesLoaderUtils#loadProperties ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: syncope   文件: XMLContentLoader.java
private void createIndexes(final String domain, final DataSource dataSource) throws IOException {
    LOG.debug("[{}] Creating indexes", domain);

    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

    Properties indexes = PropertiesLoaderUtils.loadProperties(indexesXML.getResource());
    indexes.stringPropertyNames().stream().sorted().forEachOrdered(idx -> {
        LOG.debug("[{}] Creating index {}", domain, indexes.get(idx).toString());
        try {
            jdbcTemplate.execute(indexes.getProperty(idx));
        } catch (DataAccessException e) {
            LOG.error("[{}] Could not create index", domain, e);
        }
    });

    LOG.debug("Indexes created");
}
 
源代码2 项目: mPaaS   文件: InitPropConfigFactory.java
/**
 * 配置文件信息获取
 *
 * @return
 */
@Override
public Map<String, Object> defaultConfig() {
    Map<String, Object> rtnMap = new HashMap<>(1);
    try {
        ClassLoader classLoader = this.getClass().getClassLoader();
        Enumeration<URL> urls = (classLoader != null ?
                classLoader.getResources(getPropFilePath()) :
                ClassLoader.getSystemResources(getPropFilePath()));
        while (urls.hasMoreElements()) {
            URL url = urls.nextElement();
            UrlResource resource = new UrlResource(url);
            Properties properties = PropertiesLoaderUtils.loadProperties(resource);
            for (Map.Entry<?, ?> entry : properties.entrySet()) {
                rtnMap.put((String) entry.getKey(), entry.getValue());
            }
        }
    } catch (IOException e) {
        log.error("加载初始配置错误.", e);
    }
    return rtnMap;
}
 
源代码3 项目: open-capacity-platform   文件: I18nUtil.java
public static Properties loadI18nProp(){
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18nFile = "i18n/message.properties";

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
源代码4 项目: zuihou-admin-boot   文件: I18nUtil.java
public static Properties loadI18nProp() {
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        i18n = StringUtils.isNotBlank(i18n) ? ("_" + i18n) : i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource, "UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
static Collection<BinderType> parseBinderConfigurations(ClassLoader classLoader,
		Resource resource) throws IOException, ClassNotFoundException {
	Properties properties = PropertiesLoaderUtils.loadProperties(resource);
	Collection<BinderType> parsedBinderConfigurations = new ArrayList<>();
	for (Map.Entry<?, ?> entry : properties.entrySet()) {
		String binderType = (String) entry.getKey();
		String[] binderConfigurationClassNames = StringUtils
				.commaDelimitedListToStringArray((String) entry.getValue());
		Class<?>[] binderConfigurationClasses = new Class[binderConfigurationClassNames.length];
		int i = 0;
		for (String binderConfigurationClassName : binderConfigurationClassNames) {
			binderConfigurationClasses[i++] = ClassUtils
					.forName(binderConfigurationClassName, classLoader);
		}
		parsedBinderConfigurations
				.add(new BinderType(binderType, binderConfigurationClasses));
	}
	return parsedBinderConfigurations;
}
 
源代码6 项目: DataLink   文件: PropertiesUtil.java
/**
 * 获取properties文件内容
 *
 * @param propertiesPath :绝对路径
 * @return
 */
public static Properties getProperties(String propertiesPath) throws IOException {

    Properties resultProperties = propertiesMap.get(propertiesPath);

    if (resultProperties == null) {
        Resource resource = new PathResource(propertiesPath);
        try {
            resultProperties = PropertiesLoaderUtils.loadProperties(resource);
        } catch (FileNotFoundException e) {
            resultProperties = null;
        }

        if (resultProperties != null)
            propertiesMap.put(propertiesPath, resultProperties);
    }

    return resultProperties;
}
 
源代码7 项目: awesome-delay-queue   文件: Config.java
@Bean
public AwesomeURL awesomeUrl() throws IOException {
    String configPath = storage+".properties";
    Resource resource = new ClassPathResource(configPath);
    Properties props = PropertiesLoaderUtils.loadProperties(resource);
    Set<String> keySet = props.stringPropertyNames();
    String host = props.getProperty("host");
    int port = Integer.parseInt(props.getProperty("port"));
    String username = props.getProperty("username");
    String password = props.getProperty("password");
    Map<String,String> paramMap = new HashMap<>();
    for (String key:keySet){
        paramMap.put(key, (String) props.get(key));
    }
    AwesomeURL awesomeURL = new AwesomeURL(storage,username,password,host,port,null,paramMap);
    return awesomeURL;
}
 
源代码8 项目: xmfcn-spring-cloud   文件: I18nUtil.java
public static Properties loadI18nProp(){
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        i18n = StringUtils.isNotBlank(i18n)?("_"+i18n):i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource,"UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
源代码9 项目: zuihou-admin-cloud   文件: I18nUtil.java
public static Properties loadI18nProp() {
    if (prop != null) {
        return prop;
    }
    try {
        // build i18n prop
        String i18n = XxlJobAdminConfig.getAdminConfig().getI18n();
        i18n = StringUtils.isNotBlank(i18n) ? ("_" + i18n) : i18n;
        String i18nFile = MessageFormat.format("i18n/message{0}.properties", i18n);

        // load prop
        Resource resource = new ClassPathResource(i18nFile);
        EncodedResource encodedResource = new EncodedResource(resource, "UTF-8");
        prop = PropertiesLoaderUtils.loadProperties(encodedResource);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return prop;
}
 
源代码10 项目: open-capacity-platform   文件: PropertiesUtil.java
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;
}
 
源代码11 项目: wangmarket   文件: ApplicationProperties.java
public ApplicationProperties() {
	try {
           Resource resource = new ClassPathResource("/application.properties");//
           properties = PropertiesLoaderUtils.loadProperties(resource);
       } catch (IOException e) {
           e.printStackTrace();
       }
}
 
源代码12 项目: Moss   文件: ManagementEnvironmentCustomizer.java
@Override
public void customize(ConfigurableEnvironment env) {
    try {
        Properties props;
        ClassPathResource resource = new ClassPathResource(DEFAULT_PROPERTY);
        props = PropertiesLoaderUtils.loadProperties(resource);
        props.put(SPRINGBOOT_MANAGEMENT_PORT_KEY, getManagementPort(env));
        env.getPropertySources().addLast(new PropertiesPropertySource("managementProperties", props));
    } catch (IOException e) {
        logger.error("Failed to load " + DEFAULT_PROPERTY);
    }
}
 
源代码13 项目: Moss   文件: ManagementEnvironmentCustomizer.java
@Override
public void customize(ConfigurableEnvironment env) {
    try {
        Properties props;
        ClassPathResource resource = new ClassPathResource(DEFAULT_PROPERTY);
        props = PropertiesLoaderUtils.loadProperties(resource);
        props.put(SPRINGBOOT_MANAGEMENT_PORT_KEY, getManagementPort(env));
        env.getPropertySources().addLast(new PropertiesPropertySource("managementProperties", props));
    } catch (IOException e) {
        logger.error("Failed to load " + DEFAULT_PROPERTY);
    }
}
 
源代码14 项目: jeesuite-config   文件: CCPropertySourceLoader.java
private Properties loadProperties(String name, Resource resource) throws IOException{
	Properties properties = null;
	if(name.contains("properties")){
		properties = PropertiesLoaderUtils.loadProperties(resource);
	}else{
		YamlPropertiesFactoryBean bean = new YamlPropertiesFactoryBean();
		bean.setResources(resource);
		properties = bean.getObject();
	}
	return properties;
}
 
源代码15 项目: citrus-admin   文件: ProjectService.java
/**
 * Reads default Citrus project property file for active project.
 * @return properties loaded or empty properties if nothing is found
 */
public Properties getProjectProperties() {
    File projectProperties = fileBrowserService.findFileInPath(new File(project.getProjectHome()), "citrus.properties", true);

    try {
        if (projectProperties != null) {
            return PropertiesLoaderUtils.loadProperties(new FileSystemResource(projectProperties));
        }
    } catch (IOException e) {
        log.warn("Unable to read default Citrus project properties from file resource", e);
    }

    return new Properties();
}
 
源代码16 项目: pig   文件: PigResourcesGenerator.java
/**
 * 获取配置文件
 *
 * @return 配置Props
 */
private static Properties getProperties() {
    // 读取配置文件
    Resource resource = new ClassPathResource("/config/application.properties");
    Properties props = new Properties();
    try {
        props = PropertiesLoaderUtils.loadProperties(resource);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return props;
}
 
源代码17 项目: rebuild   文件: AesPreferencesConfigurer.java
/**
    * 从安装文件加载配置
    *
    * @return
    * @see #INSTALL_FILE
    */
private Properties fromInstallFile() {
       File file = SysConfiguration.getFileOfData(INSTALL_FILE);
       if (file.exists()) {
           try {
               return PropertiesLoaderUtils.loadProperties(new FileSystemResource(file));
           } catch (IOException e) {
               throw new SetupException(e);
           }
       }
       return new Properties();
   }
 
源代码18 项目: MicroCommunity   文件: SystemStartUpInit.java
/**
 * 加载文件
 * @param location
 * @param filename
 * @param
 */
private Properties load(String location,String filename) throws Exception{
    Properties properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource(location+filename));
    return properties;
}
 
/**
 * 加载文件
 * @param location
 * @param filename
 * @param
 */
private static  Properties load(String location,String filename) throws Exception{
    Properties properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource(location+filename));
    return properties;
}
 
源代码20 项目: MicroCommunity   文件: EventConfigInit.java
/**
 * 加载文件
 * @param location
 * @param filename
 * @param
 */
private  static Properties load(String location,String filename) throws Exception{
    Properties properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource(location+filename));
    return properties;
}