0

this is my declaration of the bean

@Bean
public Set<Long> getIds(){
return new HashSet<Long>();
}

and this is how i use and autowired it.

@Autowired
@Qualifier("getIds")
private Set<Long> listIds;

somehow it just wont create the bean and eventually raise a there is no qualifying bean. but if I change the datatype to String it works just fine. I wonder what is wrong with my code.

kenlz
  • 461
  • 7
  • 22
  • Put a log statement in the `@Bean` method. Does that get logged? – Sotirios Delimanolis Apr 28 '16 at 04:29
  • nope, but i tried creating a constructor in my configuration class and it logged it. and somehow missed creating the bean like its trying to autowire first instead of creating the bean. – kenlz Apr 28 '16 at 04:39
  • Take a look at the duplicate. You won't be able to inject beans of type `Collection` with `@Autowired`. You'll want to use `@Resource` and set its `name`. – Sotirios Delimanolis Apr 28 '16 at 04:42
  • Yes @SotiriosDelimanolis sorry i kind of missed it. It solved the problem. thanks alot! – kenlz Apr 28 '16 at 05:27

0 Answers0