第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

一直提示這個bean沒有被定義 我明明定義了的哪里出錯了

package?com.autowiring;

public?class?AutoService?{
????private?AutoDao?aotudao1;

	public?AutoService(AutoDao?aotudao1){
		System.out.println("AutoService構(gòu)造方法");
		this.aotudao1?=?aotudao1;
	}
	
	public?void?setAotudao1(AutoDao?aotudao1)?{
		System.out.println("AutoService?set方法");
		this.aotudao1?=?aotudao1;
	}
	public?void?say(String?word)?{
	?????this.aotudao1.say(word);
		
	}
}
package?com.autowiring;

import?org.junit.Test;

import?com.imooc.test.base.UnitTestBase;

public?class?AutoTest?extends?UnitTestBase{
????????public?AutoTest(){
????????	super("classpath*:spring.autowiring.xml");
????????}
?????????@Test
????????public?void?testbyname(){
????????	AutoService?Service=super.getBean("auto");
????????	Service.say("hello");
????????}
}
<?xml?version="1.0"?encoding="UTF-8"?>
<beans?xmlns="http://www.springframework.org/schema/beans"
????xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
????xsi:schemaLocation="http://www.springframework.org/schema/beans
????????http://www.springframework.org/schema/beans/spring-beans.xsd"
??????default-autowire="byName">
????????
	<bean?id="aotudao1"?class="com.autowiring.AutoDao"??></bean>
	<bean?id="auto"?class="com.autowiring.AutoService">
	</bean>
?</beans>
package?com.autowiring;

public?class?AutoDao?{
?????public?void?say(String?word){
????	?System.out.println("這是Dao層:"+word);
?????}
}

錯誤信息:No bean named 'auto' is defined


我的配置文件哪里錯了

正在回答

4 回答

沒有默認(rèn)的無參構(gòu)造方法,這個需要添加AutoService的無參構(gòu)造方法,不然值為byname或者byType時候AutoService的構(gòu)造函數(shù)會報錯吧

0 回復(fù) 有任何疑惑可以回復(fù)我~

<bean />

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

丶子非魚 提問者

有啊 你自己看
2017-06-12 回復(fù) 有任何疑惑可以回復(fù)我~

把 main 方法也放出來吧

0 回復(fù) 有任何疑惑可以回復(fù)我~

在用?default-autowire的時候值為byname和bytype時 ?不能添加構(gòu)造方法 ? 在用constractor時可以用set方法

坑啊 ?這是為什么

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

一直提示這個bean沒有被定義 我明明定義了的哪里出錯了

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號