加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

SystemProperties读取资源文件.properties文件的配置属性

发布时间:2020-12-17 01:26:31 所属栏目:安全 来源:网络整理
导读:SystemProperties.java属性类是读取src下面的visaManagement.properties配置文件,具体如下所示: ? import java.io.IOException; import java.util.Properties; import org.apache.log4j.Logger; /** ?* 系统配置文件 ?* ?*/ public class SystemProperties

SystemProperties.java属性类是读取src下面的visaManagement.properties配置文件,具体如下所示:

?

import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
?* 系统配置文件
?*
?*/
public class SystemProperties {

?//日志
?private static Logger logger = Logger.getLogger(SystemProperties.class);
?
?private static Properties systemProperties = new Properties();
?
?/**
? * 报文发送地址URL
? */
?
?public static final String WEBSERVICE_URL = "webService.url";
?
?/**
? * 是否加密
? */
?public static final String IS_ENCRYPT = "isEncrypt";
?
?/**
? * 报表存放路径
? */
?public static final String? REPORT_DIR= "report.dir";
?
?/**
? * 报表文件类型
? */
?public static final String FILE_TYPE = "file.type";
?
?static{
??try {
???systemProperties.load(SystemProperties.class.getResourceAsStream("/visaManagement.properties"));
??} catch (IOException e) {
???logger.error("加载system.properties文件失败");
???e.printStackTrace();
??}
??
?}
?
?/**
? * 从.properties文件中得到相应属性的值
? */
?public static String getProperty(String property){
??return systemProperties.getProperty(property);
?}
?
}

?

visaManagement.properties配置文件如下所示:

?

webService.url=http://120.21.210.21:8080/service

isEncrypt = true
#isEncrypt = false

#----Path of report
report.dir = D:/workspaces/gpicSpace/e-cargo/cargo-online/template

file.type = .jasper

ip = 000000000000006

?

?

在其他地方想要获得visaManagement.properties配置文件中的某个参数的值可调用SystemProperties.getProperty("ip")来获得

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读