In module1.jar:
<bean id="customerService" class="com.service.CustomCustomerServiceImpl" > </bean>
In module2.jar:
<bean id="customerService" class="com.service.CustomerServiceImpl" > </bean>
public class CustomerController {
@Autowired
protected CustomerService customerService;
// getters and setters
}
I see CustomerService is injected with CustomCustomerServiceImpl always.
My question is should an exception be thrown while starting the server since there are two beans (CustomCustomerServiceImpl and CustomerServiceImpl) of type CustomerService.
Should not spring throw exception?
How spring is able to resolve the autowire annotation by type here when multiple beans are found?
Update :-
public class CustomCustomerServiceImpl extends CustomerServiceImpl {}