ResourceBundleMessageSource和ReloadableResourceBundleMessageSource

ResourceBundleMessageSource只能读取classpath中的文件

ReloadableResourceBundleMessageSource可以读取外部文件


    
    
        
            classpath:bundles/resource
            classpath:bundles/override
            file:C:/mmt/override
        
    
注意外部文件的写法,
file:/path/to/messages

如果要动态刷新必须加一下配置

否则不会动态刷新


setCacheSeconds

public void setCacheSeconds(int cacheSeconds)
Set the number of seconds to cache loaded properties files.
  • Default is "-1", indicating to cache forever (just likejava.util.ResourceBundle).
  • A positive number will cache loaded properties files for the givennumber of seconds. This is essentially the interval between refresh checks.Note that a refresh attempt will first check the last-modified timestampof the file before actually reloading it; so if files don't change, thisinterval can be set rather low, as refresh attempts will not actually reload.
  • A value of "0" will check the last-modified timestamp of the file onevery message access. Do not use this in a production environment!

你可能感兴趣的:(ResourceBundleMessageSource和ReloadableResourceBundleMessageSource)