Web MVC应用程序-重新加载属性文件而无需在Java中重新启动服务器

问题描述

我有一个Web MVC Java应用程序,想要重新加载@Service类或@Repository类中的属性,而无需重新启动tomcat?有可能吗?

我使用下面的代码重新加载属性,在某些情况下它可以工作,但在@Repository类中不起作用


public class AppProperties {
    private static PropertiesConfiguration configuration = null;
    static {
        try {
            configuration = new PropertiesConfiguration("Path_to_properties");
        } catch (ConfigurationException e) {
            e.printstacktrace();
        }
        configuration.setReloadingStrategy(new FileChangedReloadingStrategy());
    }
    public static synchronized String getProperty(final String key) {       
        String prop = (String) configuration.getProperty(key);      
        return prop;
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)