在项目开发中 有写配置是写在 properties 文件中的 ,但有的时候需要更改值,但是发现需要重启服务才能生效
/**
* 初始化配置文件
*/
public void init(){
try{
InputStream is = Config.class.getResourceAsStream("/res/config.properties");
properties = new Properties();
properties.load(is);
}catch (Exception e){
throw new RuntimeException("Failed to get properties!");
}
}
所以需要 改变一下文件的输入流获取方式
String path = Config.class.getClassLoader().getResource("/res/config.properties").getPath();
InputStream is = new FileInputStream(path);
properties.load(is);