tohsj0806 发表于 2013-2-3 14:12:55

读jar中的properties

配置如果打到jar包中,会无法运行,找不到,写法就要更改成读数据流的方式。
package jp.co.ncmobile.linuxdevenv.ScreenPicker;

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

import org.apache.log4j.PropertyConfigurator;

public class LogConfiguration {
private String propertyConfigurator = "properties/log4j.properties";
Properties properties = new Properties();
public LogConfiguration(){
try{
properties.load(LogConfiguration.class.getClassLoader().getResourceAsStream(propertyConfigurator));
}catch(IOException e){
e.getStackTrace();
}
PropertyConfigurator.configure(properties);
}

}
这样写就ok了。
页: [1]
查看完整版本: 读jar中的properties