读配置文件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 ...
随机推荐
- vue.js实现购物车功能
购物车是电商必备的功能,可以让用户一次性购买多个商品,常见的购物车实现方式有如下几种: 1. 用户更新购物车里的商品后,页面自动刷新. 2. 使用局部刷新功能,服务器端返回整个购物车的页面html 3 ...
- python的数字图像处理学习(1)
导入原有的测试图片,测试图片路径,和一些方法,显示出测试图像,测试图像路径. from skimage import io,data,data_dir img_rgb=data.chelsea() i ...
- python学习 day14 (3月19日)----
04 json # 1. 用于多种语言 交互 编程语言通用数据 # 内置的 不需要安装直接导入使用 import json # 导入 # # dumps loads dump load # dic = ...
- 【转】mysql查看表空间占用情况
${database} 为数据库的名称 /*1.查看索引 (1)单位是GB*/ SELECT CONCAT(ROUND(SUM(index_length)/(**), ), ' GB') AS 'To ...
- Our Future
The world is betting on how to win the football game: But I'm betting on how to win your heart: Mayb ...
- jQuery 常用效果
hide和show 同样有 fadeInhe fadeOut 的功能 $(document).ready(function(){ $("#hide").click(function ...
- 指令发布中如何实现new新消息的提醒?
设计思路:反馈后,最急需了解反馈结果的是申请人,故给每一条反馈信息添加一个查看状态的字段,如CK_STATUS,并为这个状态设计为char(1)类型,java bean中使用integer可以实现默认 ...
- MFC 消息框
窗口类能够使用messagebox int ret = MessageBox(_T("内容"), _T("标题"), MB_OKCANCLE| //MB_OB ...
- mapnik渲染原理
https://bbs.csdn.net/topics/390853826
- sql中的CONCAT函数运用实例1
1 第一个例子 select a.*,b.name as repayment_type_value,c.name as status_value, d.product_name, CONCAT(a.d ...