5
@Override
@Autowired(required = true)
@Qualifier("hibernateCriteriaBuilder")
public void setCriteriaBuilder(IQueryCriteriaBuilder<Entity> criteriabuilder)
{
  super.setCriteriaBuilder(criteriaBuilder):
}

This in the code I have in a java file and i keep getting a error saying: "The annotation @qualifier is diallowed for this location." Can someone explain to me how I can fix this error? I have it twice in my code and have had trouble finding a solution.

Damonte Bowie
  • 55
  • 1
  • 5

1 Answers1

13

I believe you'll have more luck using it on the parameter of your method, like so:

@Override
@Autowired
public void setCriteriaBuilder(
    @Qualifier("hibernateCriteriaBuilder") IQueryCriteriaBuilder<Entity> criteriabuilder)
{
    super.setCriteriaBuilder(criteriaBuilder):
}

You cannot use @Qualifier on a method, because what if you wanted to autowire two beans instead of just one -- how would it know which one is which?

Thomas Kåsene
  • 5,301
  • 3
  • 18
  • 30