泛型注入的时候好像不能指定被注入的Bean的name?
@Configuration public class StoreConfig { @Autowired @Qualifier("stringStore") private Store<String> s1; @Bean("hello") //指定name public Store stringStore(){ return new StringStore(); } }
test:
@Test public void testG(){ Store store = super.getBean("hello"); System.out.println(store.getClass().getName()); }
当然这里@Qualifier("stringStore") ,但是我改成@Qualifier("hello"),也是一样