Jakarta ee Resourcebundle无需重新启动服务器即可重新加载JSF2-Jboss 7

Jakarta ee Resourcebundle无需重新启动服务器即可重新加载JSF2-Jboss 7,jakarta-ee,jsf-2,jboss,resourcebundle,clear-cache,Jakarta Ee,Jsf 2,Jboss,Resourcebundle,Clear Cache,我试图在运行时重新加载资源包。 在我的应用程序中,在登录之后,我将获得调用的属性。该调用是在我的应用程序基础模板中进行的,并且一切正常。属性文件位于MyApp/resources下/ 下一步是尝试更新从我的userHome/resources中的属性文件读取的resourceBundle。我所做的调用我的托管bean的工作是: File file = new File(System.getProperty("user.home")+ "/resources/"); URL[] urls

我试图在运行时重新加载资源包。 在我的应用程序中,在登录之后,我将获得调用
的属性。该调用是在我的应用程序基础模板中进行的,并且一切正常。属性文件位于MyApp/resources下/

下一步是尝试更新从我的userHome/resources中的属性文件读取的resourceBundle。我所做的调用我的托管bean的工作是:

File file = new File(System.getProperty("user.home")+ "/resources/");
    URL[] urls = {file.toURI().toURL()};
    ClassLoader loader = new URLClassLoader(urls);

    ResourceBundle.clearCache(Thread.currentThread().getContextClassLoader());  
    ResourceBundle.clearCache();
    bundle = ResourceBundle.getBundle("messages",Locale.ENGLISH, loader);
我没有得到任何错误,边界得到了正确的值,但在我的应用程序中发生了任何更改。有人可以告诉我如何重新加载捆绑包并显示从外部文件获得的新值??清除缓存似乎不起作用,我去掉了jsf2的faces-config.xml原因。。。希望有人能帮忙。

您可以用它来解决这个问题,

PropertiesConfiguration propertiesConfig = new PropertiesConfiguration("yourProps.properties");
propertiesConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
为此,您需要使用commons配置dependency/jar

<dependency>
    <groupId>commons-configuration</groupId>
    <artifactId>commons-configuration</artifactId>
    <version>20041012.002804</version>
</dependency>

共用配置
,


资源:

一件事是以编程方式加载捆绑包。另一件事是在更新它们时让它们保持刷新。我想你的目标是第二个?是的,每次我对“用户/资源”下的属性文件进行更改时,我都会刷新它们