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

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

我有個問題??????

package?main.java.com.xiaodao.bean;
public?class?BeanScope?{
public?void?say(){
System.out.println("BeanScope?say:"?+this.hashCode());
}
}
<?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"?>
????????
????????<bean?id="beanScope"?class="main.java.com.xiaodao.bean.BeanScope"?scope="singleton"></bean>
????????
?</beans>
import?org.junit.Test;
import?org.junit.runner.RunWith;
import?org.junit.runners.BlockJUnit4ClassRunner;
import?main.java.com.xiaodao.bean.BeanScope;
import?test.java.com.xiaodao.test.base.UnitTestBase;
@RunWith(BlockJUnit4ClassRunner.class)
public?class?TestBeanScope?extends?UnitTestBase?{
public?TestBeanScope()?{
super("classpath*:spring-beanscope.xml");
}
@Test
public?void?testSay()?{
BeanScope?beanScope?=?super.getBean("beanScope");
beanScope.say();
}
}



運行報錯,No bean named 'beanScope' is defined

找不到定義為beanScope的bean


正在回答

1 回答

BeanScope類上是不是應該加個@Service注解

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

舉報

0/150
提交
取消

我有個問題??????

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

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

幫助反饋 APP下載

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

公眾號

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