如果在Java中使用ResourceBundle时,缓存更新无效,可以尝试以下解决方法:
ResourceBundle.clearCache();
ResourceBundle bundle = ResourceBundle.getBundle("MyResources", new Control() {
@Override
public long getTimeToLive(String baseName, Locale locale) {
// 禁用缓存
return TTL_DONT_CACHE;
}
});
ClassLoader classLoader = new URLClassLoader(new URL[]{new File("path/to/resources").toURI().toURL()});
ResourceBundle bundle = ResourceBundle.getBundle("MyResources", Locale.getDefault(), classLoader);
通过以上方法,您应该能够解决Java中ResourceBundle缓存更新无效的问题。