本文整理汇总了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);
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
}