关于Junit显示名字找不到
<?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="OneInterface" class="com.imooc.ioc.interfaces.OneInterfaceImpl"></bean>
</beans>
显示 No bean named “OneInterface” is defined。 请问是为什么?
private ClassPathXmlApplicationContext ctx;
@Before
public void init(){
ctx = new ClassPathXmlApplicationContext("classpath*:spring-ioc.xml");//如果在src目录下则是classpath*:。如果在其他路径则在classpath*:加入路径名称如spring/
ctx.start();
}
@Test
public void test(){
OneInterface oif = (OneInterface)ctx.getBean("OneInterface");//这里为什么会显示找不到???????
System.out.println(oif.say("我输入的参数"));
}
@After
public void destory(){
ctx.destroy();
}