当前位置: 首页>>代码示例>>Java>>正文


Java PropertiesLoaderUtils.loadProperties方法代码示例

本文整理汇总了Java中org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesLoaderUtils.loadProperties方法的具体用法?Java PropertiesLoaderUtils.loadProperties怎么用?Java PropertiesLoaderUtils.loadProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.core.io.support.PropertiesLoaderUtils的用法示例。


在下文中一共展示了PropertiesLoaderUtils.loadProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processConfigFile

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
private void processConfigFile(Resource resource)
    throws IOException
{
	String absPath = null;
	if (null != resource.getURL() && !resource.getURL().getFile().contains("jar!"))
	{
		absPath = resource.getFile().getAbsolutePath();
	}
    LOGGER.info("Loading configuration file " + resource.getFilename() + " from " + absPath + "|" + resource);
    Properties props = PropertiesLoaderUtils.loadProperties(resource);
    ConfigFile configFile = new ConfigFile();
    configFile.setFileName(resource.getFilename());
    configFile.setFilePath(absPath);
    configFile.setConfigList(parseConfigFile(props));
    CONFIG_FILES.add(configFile);
}
 
开发者ID:Huawei,项目名称:eSDK_EC_SDK_Java,代码行数:17,代码来源:ConfigManagerNoDecrypt.java

示例2: postProcessEnvironment

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
		SpringApplication application) {
	File home = getHomeFolder();
	File propertyFile = (home == null ? null : new File(home, FILE_NAME));
	if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {
		FileSystemResource resource = new FileSystemResource(propertyFile);
		Properties properties;
		try {
			properties = PropertiesLoaderUtils.loadProperties(resource);
			environment.getPropertySources().addFirst(
					new PropertiesPropertySource("devtools-local", properties));
		}
		catch (IOException ex) {
			throw new IllegalStateException("Unable to load " + FILE_NAME, ex);
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:DevToolsHomePropertiesPostProcessor.java

示例3: getOpenAccount

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
public static Object getOpenAccount(String propertyName, Object obj, String openAccountStr,
        String openAccountUrlStr) {
    try {
        Resource resource = new ClassPathResource(propertyName);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        String openAccount = props.getProperty(openAccountStr);
        String openAccountUrl = props.getProperty(openAccountUrlStr);
        if (obj instanceof BlogModel) {
            BlogModel blogModel = (BlogModel) obj;
            blogModel.setOpenAccount(openAccount);
            blogModel.setOpenAccountUrl(openAccountUrl);
            return blogModel;
        } else {
            NoticeModel noticeModel = (NoticeModel) obj;
            noticeModel.setOpenAccount(openAccount);
            noticeModel.setOpenAccountUrl(openAccountUrl);
            return noticeModel;
        }
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:23,代码来源:Property.java

示例4: getPropert

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
@Override
public void getPropert() {
    filter = new HashMap<String, String>();
    allMassage = new ArrayList<String>();
    try {
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        providerMap = Maps.newConcurrentMap();
        Provider provider = new Provider();
        provider.setHost(props.getProperty("host"));
        provider.setTurnPage(props.getProperty("turn_page"));
        provider.setBankType(props.getProperty("bank_type"));
        provider.setReferenceInformation(props.getProperty("reference_information"));
        provider.setThreadNum(props.getProperty("user_thread"));

        providerMap.put("provider", provider);
    } catch (Exception e) {
        LOG.warn("read profiles from yichen", e);
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:21,代码来源:Entrace.java

示例5: loadProperties

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
/**
 * 从configx.properties文件读取属性
 */
private void loadProperties() {
    Resource configxClientProperties = new ClassPathResource("configx.properties");
    if (configxClientProperties.exists()) {
        try {
            Properties defaultProperties = PropertiesLoaderUtils.loadProperties(configxClientProperties);
            PropertySource<?> defaultPropertySource = new PropertiesPropertySource("configxClientProperties", defaultProperties);
            this.environment.getPropertySources().addLast(defaultPropertySource);
        } catch (IOException e) {
            logger.error("Failed to load configx.properties", e);
        }
    }
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:16,代码来源:ConfigContext.java

示例6: getString

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
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;
}
 
开发者ID:mmwhd,项目名称:stage-job,代码行数:15,代码来源:PropertiesUtil.java

示例7: run

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
@Override
public void run(String... args) throws Exception {
	Properties properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource("generator.properties"));
	String nodeName = properties.getProperty("mybatis.nodeName", null);
	Assert.hasText(nodeName, "节点名不可以为空");
	MybatisNodeProperties node = this.getNodeBYName(nodeName);
	this.buildProperties(properties, node);

	Assert.hasText(properties.getProperty("package.model"), "mapper的model目录不可以为空,配置项 package.model");
	Assert.hasText(properties.getProperty("package.repo"), "mapper的接口目录不可以为空,配置项 package.repo");
	Assert.hasText(properties.getProperty("package.mapper"), "mapper的xml目录不可以为空,配置项 package.mapper");

	this.generate(properties);

}
 
开发者ID:halober,项目名称:spring-boot-starter-dao,代码行数:16,代码来源:GeneratorMain.java

示例8: getProperties

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
/**
 * 获取配置文件
 *
 * @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;
}
 
开发者ID:TomChen001,项目名称:xmanager,代码行数:17,代码来源:MysqlGenerator.java

示例9: getPropert

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
@Override
public void getPropert() {
    try {
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        providerMap = Maps.newConcurrentMap();
        Provider provider = new Provider();
        provider.setHost(props.getProperty("zn_envPRDHost"));
        provider.setMarket(Integer.parseInt(props.getProperty("zn_market")));
        providerMap.put("provider", provider);
    } catch (Exception e) {
        throw new RuntimeException("读取配置文件出错!", e);
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:15,代码来源:ZnTradeProvider.java

示例10: init

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
public static void init() {
	try {
		Resource r = new ClassPathResource("/META-INF/logx.properties");
		Properties p = PropertiesLoaderUtils.loadProperties(r);
		String domain = p.getProperty("logx.domain");
		config.put("logx.domain", domain);
		config.put("logx.host", getLocalIP());
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Percy0601,项目名称:log-extension,代码行数:12,代码来源:PropertiesConfig.java

示例11: deployEnvionment

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
@RequestMapping(value = "/watch/{group}/{envionment}/{project}", method = RequestMethod.GET)
public ModelAndView deployEnvionment(@PathVariable String group, @PathVariable String envionment, @PathVariable String project) throws IOException {
	properties = PropertiesLoaderUtils.loadProperties(new ClassPathResource(String.format("/%s/%s/%s.properties", group, envionment, project)));
	ModelAndView modelAndView = new ModelAndView("logging/watch");
	modelAndView.addObject("project", project);
	modelAndView.addObject("groups", group);
	modelAndView.addObject("envionment", envionment);
	modelAndView.addObject("logs", properties.keySet());
	// log.info(String.valueOf(properties.get("group")).concat(","));
	return modelAndView;
}
 
开发者ID:oscm,项目名称:web,代码行数:12,代码来源:LoggingController.java

示例12: mongoDbFactory

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
public
@Bean
MongoDbFactory mongoDbFactory() throws Exception {
    Resource resource = new ClassPathResource("/runtime.properties");
    Properties props = PropertiesLoaderUtils.loadProperties(resource);
    String uriStr = props.getProperty("mongo.url.dev", "");

    return new SimpleMongoDbFactory(new MongoClientURI(uriStr));
}
 
开发者ID:mikeqian,项目名称:house,代码行数:10,代码来源:AppConfig.java

示例13: loadKafkaProperties

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
public static Properties loadKafkaProperties() throws IOException {
    String kafkaPath = System.getProperty("kafkaProduce");
    if (StringUtils.isEmpty(kafkaPath)) {
        kafkaPath = DEFAULT_KAFKA_PATH;
    }

    return PropertiesLoaderUtils.loadProperties(new FileSystemResource(kafkaPath));
}
 
开发者ID:kevinKaiF,项目名称:cango,代码行数:9,代码来源:PropertiesFileLoader.java

示例14: load

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
public static Properties load(String path) throws IOException {
    if (StringUtils.isEmpty(path)) {
        return new Properties();
    }

    return PropertiesLoaderUtils.loadProperties(new FileSystemResource(path));
}
 
开发者ID:kevinKaiF,项目名称:cango,代码行数:8,代码来源:PropertiesFileLoader.java

示例15: getPropert

import org.springframework.core.io.support.PropertiesLoaderUtils; //导入方法依赖的package包/类
@Override
public void getPropert() {
    try {
        Resource resource = new ClassPathResource(PROPERTY_NAME);
        Properties props = PropertiesLoaderUtils.loadProperties(resource);
        providerMap = Maps.newConcurrentMap();
        Provider provider = new Provider();
        provider.setHost(props.getProperty("hb_envPRDHost"));
        provider.setMarket(Integer.parseInt(props.getProperty("hb_market")));
        providerMap.put("provider", provider);
    } catch (Exception e) {
        throw new RuntimeException("读取配置文件出错!", e);
    }
}
 
开发者ID:pipingyishi,项目名称:test,代码行数:15,代码来源:HbTradeProvider.java


注:本文中的org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。