我的应用程序有不同的客户(20左右),每个客户都有自己的*.properties
文件与连接设置,属性参数相同。区分多个属性文件
目前,我已经为每个客户提供了一种自己的方法来读取属性并将其存储在Customer
中。与20个客户,其充气。我正在寻找更好的解决方案。
private final static Customer get_CustomerXXXX() {
final Properties p = new Properties();
p.load(S.class.getResourceAsStream("customerXXX.properties"));
return new Customer (p.getProperty("PARAM1", p.getProperty("PARAM2", p.getProperty("PARAM3")
}
if(SPECIFIC_CUSTOMER.XXXX) {
customerSettings = get_CustomerXXXX();
} else if(SPECIFIC_CUSTOMER.BBBB) {
customerSettings = get_CustomerBBBB();
}
*请*格式化代码时要注意。目前这一切都在这个地方。请记住,Stack Overflow的目标是成为高质量问题和答案的存储库 - 不可读的代码会降低该目标。 –