注解代码
@Bean(name = "stringStore") @Scope(value="prototype", proxyMode = ScopedProxyMode.TARGET_CLASS) public Store stringStore() { return new StringStore(); }
测试代码
@Test public void testScope() { Store store = super.getBean("stringStore"); System.out.println(store.hashCode()); store = super.getBean("stringStore"); System.out.println(store.hashCode()); }
两个对象的hashCode是不同的,英文Scope中设置为prototype