为什么我设置了prototype 测试的结果还是singleton?
Java代码:
ApplicationContext context;
public OneInterfaceImplTest() {
context = new ClassPathXmlApplicationContext("spring-ioc.xml");
}
@Test
public void test() {
OneInterface oneInterface1 = (OneInterface) context.getBean("oneInterface");
System.out.println(oneInterface1.hello2("123"));
// ApplicationContext context1 = new ClassPathXmlApplicationContext("spring-ioc2.xml");
OneInterface oneInterface2 = (OneInterface) context.getBean("oneInterface");
System.out.println(oneInterface2.hello2("123"));
}
配置项:<bean class="daoImpl.InjectionDAOImpl" id="InjectionDAO" scope="prototype"></bean>
impl方法:
@Override
public String hello2(String string) {
// TODO Auto-generated method stub
return "" + this.hashCode();
}