读配置文件property文件
import java.io.IOException;
import java.util.Properties; import org.springframework.core.io.support.PropertiesLoaderUtils; /**
* Description: 读取配置文件http地址配置<br>
*/
public class ConfigFileUtils { /**
* 读取authconfig.properties
*
* @param nodeName
* @return
*/
public static String getAuthconfig(String nodeName) {
String configName = "application.properties";
String result = pubReadConfig(configName, nodeName);
if (result == null) {
result = pubReadConfig("prop/" + configName, nodeName);
}
return result;
} /**
* 通用读取方法
*
* @param configName
* @param nodeName
* @return
*/
public static String pubReadConfig(String configName, String nodeName) {
Properties props = new Properties();
while (true) {
try {
props = PropertiesLoaderUtils.loadAllProperties(configName);
return (String) props.get(nodeName);
} catch (IOException e) {
System.out.println(e.getMessage());
}
}
}
}
读配置文件property文件的更多相关文章
- 使用Spring的Property文件存储测试数据 - 初始化
本系列博客有一个前提:只使用Junit编写测试,不使用类似Cucumber这类BDD框架. 用Cucumber的时候,测试数据可以直接写在feature文件里,但是仅仅使用Junit(不要问我为什么只 ...
- spring 配置文件 引入外部的property文件的两种方法
spring 的配置文件 引入外部的property文件的两种方法 <!-- 引入jdbc配置文件 方法一 --> <bean id="propertyConfig ...
- Spring property文件配置方法以及如何与工程分离
1,Spring使用property文件作为配置源 工程中难免出现一些需要每次部署都需要配置的参数,如数据源连接参数等,测试环境跟实际运行环境是不一样的. 使用spring框架的话,这些参 ...
- java读取property文件
property文件中: url = jdbc:mysql://localhost:3306/resume user= root pwd = 123 java代码读取: packa ...
- Java解析property文件(和静哥说的,SQL执行限定时间写在xml中,增加扩展,在不改源代码基础上)
在Java项目中一些配置参数保存在Property文件中,这样能保证不修改原代码直接修改Property文件. 简单的很,就是在java文件中读取外界的properyt配置文件 PropertyPar ...
- 使用 <!-- 指定使用hibernate核心配置文件 --> <property name="configLocations" value="classpath:hibernate.cfg.xml"></property>
在bean.xml文件中,这样使用出现问题 <!-- 指定使用hibernate核心配置文件 --> <property name="configLocations&quo ...
- java加载property文件配置
1 properties简介: properties是一种文本文件,内容格式为: key = value #单行注释 适合作为简单配置文件使用,通常作为参数配置.国际化资源文件使用. ...
- property_自己编写一个读取Property文件的Util类
读取property文件的Util类: 所需jar包: 编写PropertiesUtil类: package com.west.util.property; import java.io.InputS ...
- [C++基础]一个比较常用的配置文件/初始化文件读取程序
在编程中,我们经常会遇到一些配置文件或初始化文件.这些文件通常后缀名为.ini或者.conf,可以直接用记事本打开.里面会存储一些程序参数,在程序中直接读取使用.例如,计算机与服务器通信,服务器的ip ...
随机推荐
- day05作业---字典
# 字典找位置 用键, 列表.元组找位置 用索引'''1.有如下变量(tu是个元祖),请实现要求的功能tu = ("alex", [11, 22, {"k1": ...
- Our Future
The world is betting on how to win the football game: But I'm betting on how to win your heart: Mayb ...
- 第23章:MongoDB-聚合操作--聚合命令
①count() 范例:统计students表中的数据量 db.students.count(); 范例:模糊查询 db.students.count("name":/张/i); ...
- vue2.0路由-路由嵌套
vue一个重要的方面就是路由,下面是自己写的一个路由的例子: 1.引入依赖库就不必再说 2.创建组件 两种写法 第一种:间接 <template id="home"> ...
- Sql Server用户名和登录名的关系总结
以前经常被SQL Server中的用户名和登录名搞迷糊,因为用sa(登录名)就搞定一切东西了,当然这会存在一些安全隐患.网上的文章也貌似讲得很好,但还是不明白.今天决心把这个问题弄明白.mashall ...
- Ng第二课:单变量线性回归(Linear Regression with One Variable)
二.单变量线性回归(Linear Regression with One Variable) 2.1 模型表示 2.2 代价函数 2.3 代价函数的直观理解 2.4 梯度下降 2.5 梯度下 ...
- virtualbox centos 连接网络
一.设置网络 设置 -> 网络 -> 连接方式:桥接网卡.设置当前连网络的界面名称.接入网线打勾 二.开启eth0 vi /etc/sysconfig/network-scripts/if ...
- HDU3488 Tour
Tour Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submi ...
- Codeforces Round #265 (Div. 2) D. Restore Cube 立方体判断
http://codeforces.com/contest/465/problem/D 给定8个点坐标,对于每个点来说,可以随意交换x,y,z坐标的数值.问说8个点是否可以组成立方体. 暴力枚举即可, ...
- html5 实现qq聊天的气泡效果
教程:http://m.blog.csdn.net/blog/yhc13429826359/38778337 写的很好.自己实现的时候,由于img float:left,会脱离文档流,导致结构混乱. ...