java在程序启动时读取配置文件,并加载到内存中。

(1)application.propertieshtml

...
redis.ip=xxx.xxx.xxx.xxx
...

(2)工具类java

语言 主方法
282PP qE2nOWrHx5
2Dxy2 互联网创业
iq730 OdU6721k04
import java.util.ResourceBundle;

public class SystemConfig {
    static String configFile="application";
    public static String getConfigInformation(String itemIndex){
        try{
            ResourceBundle resource = ResourceBundle.getBundle(configFile);
            return resource.getString(itemIndex);
        }catch (Exception e){
            return "";
        }
    }
}
相关文章
相关标签/搜索