亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用@ConfigurationProperties(prefix = "demo")注解修飾的類注入不進來

使用@ConfigurationProperties(prefix = "demo")注解修飾的類注入不進來

小波66 2018-09-12 20:32:27
@ConfigurationProperties(prefix = "imooc.security")public class SecurityProperties {.......}@RestControllerpublic class BrowserSecurityController {@Autowired private SecurityProperties securityProperties;}啟動運行會報錯:***************************APPLICATION FAILED TO START***************************Description:Field securityProperties in com.imooc.security.browser.BrowserSecurityController required a bean of type 'imooc.security.core.properties.SecurityProperties' that could not be found.Action:Consider defining a bean of type 'imooc.security.core.properties.SecurityProperties' in your configuration.
查看完整描述

2 回答

?
Delete94

TA貢獻1條經驗 獲得超0個贊

解決了嗎?樓主

查看完整回答
反對 回復 2019-04-15
?
chandou

TA貢獻22條經驗 獲得超11個贊

少了一個注解注入到spring容器中,在你的class類SecurityProperties上增加注解@component即可

查看完整回答
反對 回復 2018-09-12
  • 小波66
    小波66
    加了這個@Component注解還是不可以,報相同的錯誤。 當我把 自動注入的給注釋掉,項目能跑起來 @Autowired private SecurityProperties securityProperties;
  • chandou
    chandou
    按照報錯信息就是沒有將properties注入到容器中,去掉自動注入properties當然可以了,去掉后啟動的時候不從容器中找這個配置文件的bean了,就不會報錯
  • 2 回答
  • 0 關注
  • 9367 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號