springboot对象方式注入
生活随笔
收集整理的這篇文章主要介紹了
springboot对象方式注入
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
注意: 這種方式必須提供SET方法
# 1. @ConfigurationProperties(prefix="前綴") @Component @ConfigurationProperties(prefix = "user") public class User {private String id;private String name;private Integer age;private String bir;//set 方法一定要提供 } # 2. 編寫配置文件 user:id: 24name: xiaoheiage: 23bir: 2012/12/12 # 3. 引入依賴構建自定義注入元數據 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional> </dependency>總結
以上是生活随笔為你收集整理的springboot对象方式注入的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JSP模板集成
- 下一篇: springboot基本属性注入