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

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么在eclipse當中,第一種注入list的方式會報錯,而第二種不會?

為什么在eclipse當中,第一種注入list的方式會報錯,而第二種不會?

正在回答

3 回答

注入List類型的bean時,由于@Autowired按類型注入的,找不到對應List中String類型的Bean,所以報錯,用@Resource替代即可。

1 回復 有任何疑惑可以回復我~

我第一種注入list也會報錯

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myBean': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void springzhuru.MyBean.setStringList(java.util.List); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [java.lang.String] found for dependency [collection of java.lang.String]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}


0 回復 有任何疑惑可以回復我~

可能是你忘記寫@Bean了

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么在eclipse當中,第一種注入list的方式會報錯,而第二種不會?

我要回答 關注問題
微信客服

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

幫助反饋 APP下載

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

公眾號

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