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 "";
        }
    }
}
相關文章
相關標籤/搜索