spring boot1.5以上版本@ConfigurationProperties取消location註解後的替代方案

  1. @EnableConfigurationProperties取消激活自定義的配置類
  2. 在配置類中採用@Component的方式註冊爲組件,而後使用@PropertySource來指定自定義的資源目錄
    @Component
    @ConfigurationProperties(prefix = "author")
    @PropertySource("classpath:author.properties")
    public class AuthorSetting {}
相關文章
相關標籤/搜索