Friday, July 15, 2011

Spring autowired behaviour

2 classes implement the same interface, 2 beans defined in configuration file for 2 different implementations.
eg. I have 2 beans of the same interface BillManager.

@Autowired
BillManager manager;

org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type...

solution:
import org.springframework.beans.factory.annotation.Qualifier;

@Autowired
@Qualifier(value = "billManagerImpl_1") //write bean ID or name
BillManager manager;

No comments:

Post a Comment