Java war包取之外的properties文件

由于服务器发布war项目不尽相同,所以获取properties也不尽相同。

tomcat:

Properties config = new Properties();
String url = Thread.currentThread().getContextClassLoader().getResource("").getPath().replaceAll("%20", " ");
String path = url.substring(0, url.indexOf(APPLICATION_NAME)) + PROPERTIES_FILE_NAME;
config.load(new FileInputStream(path));

glassfish:

question:

I'm currently migrating from WebSphere 6.1 to Glassfish v3, I managed to deploy an application but I'm stuck trying to locate where to put the properties files and getting the application find them.
On WebSphere 6.1 was something like "/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/properties"
Where would that be for GlassFish v3? "/opt/oracle/glassfishv3/glassfish/domains/domain1/.......?"

answer:

you could put the properties file into the lib/classes directory of your domain. Everything in that directory gets added to the classpath.

转载于:https://www.cnblogs.com/voctrals/archive/2013/04/12/3016624.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值