課程
/后端開發(fā)
/Java
/2小時學(xué)會Spring Boot
頁面顯示空白,不報錯,斷點輸出是name=NULL,age=null,system一個東西也能在控制臺顯示,就是沒法獲取yml中設(shè)置的值,這是為什么?
所有代碼和視頻一樣的。
2018-09-13
源自:2小時學(xué)會Spring Boot 3-1
正在回答
我的也是這樣,你解決了嗎
package?com.example.girl; import?org.springframework.boot.context.properties.ConfigurationProperties; import?org.springframework.stereotype.Component; @Component @ConfigurationProperties(prefix?=?"girl") public?class?GirlProperties?{ ????private?String?name; ????private?Integer?age; ????public?String?getName()?{ ????????return?name; ????} ????public?void?setName(String?name)?{ ????????this.name?=?name; ????} ????public?Integer?getAge()?{ ????????return?age; ????} ????public?void?setAge(Integer?age)?{ ????????this.age?=?age; ????} } --------------- package?com.example.girl; import?org.springframework.beans.factory.annotation.Autowired; import?org.springframework.web.bind.annotation.*; @RestController public?class?HelloController?{ ????@Autowired ????private?GirlProperties?girlProperties; ????@RequestMapping(value?=?"/hello",method?=?RequestMethod.GET) ????public?String?say(){ ???????return?girlProperties.getName(); ????} } ——————————————————- girl: ??name:?abc ??age:?1231
舉報
Spring Boot入門視頻教程,你將學(xué)會使用Spring Boot快速構(gòu)建應(yīng)用程序
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-10-25
我的也是這樣,你解決了嗎
2018-09-13