當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Spring Boot(四)Spring Boot @ConfigurationProperties实例
生活随笔
收集整理的這篇文章主要介紹了
Spring Boot(四)Spring Boot @ConfigurationProperties实例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Spring Boot @ConfigurationProperties實例
一 、 ConfigurationProperties的使用
通常,我們使用@Value注釋來逐個注入.properties值,這對于小而簡單的結構.properties文件很有用。
文件:global.propertiesemail=test@yiibai.com thread-pool=12使用@Value
@Component @PropertySource("classpath:global.properties") public class GlobalProperties {@Value("${thread-pool}")private int threadPool;@Value("${email}")private String email;//getters and setters}使用@ConfigurationProperties
@Component @PropertySource("classpath:global.properties") @ConfigurationProperties public class GlobalProperties {private int threadPool;private String email;//getters and setters}總結
以上是生活随笔為你收集整理的Spring Boot(四)Spring Boot @ConfigurationProperties实例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring Boot(三) 将war文
- 下一篇: windows 下终止指定端口的进程