javaspringautowiredentity-bean

Multiple field with identical name in Spring


I've got the following:

public class ClaimFacadeImpl implements ClaimFacade {

    @Autowired
    private DebtRepository<Claim> debtRepository;

    @Autowired
    private DebtRepository<Fine> fineRepository;

    //other stuff

}

public interface DebtRepository <T extends Debt> {
   //nothing special
}

public class DebtRepositoryImpl <T extends Debt> implements DebtRepository <T> {
   //nothing special
}

and 2 classes. One Claim and one Fine both extending Debt. I'm getting the error More than one field with type interface domain.debt.DebtRepository

what should I do?


Solution

  • Upgrade to Spring 4.0 if you have not done it already:

    See http://spring.io/blog/2013/12/03/spring-framework-4-0-and-java-generics