Issue
I have an interface:
public interface EmailSender {
void send(Locale locale, List<User> recipients, int ticketId);
}
And few different implementations, and I want to autowire a HashMap
of them, to have possibility to get concrete realization by class name, but when I write:
@Autowired
private HashMap<String, EmailSender> emailSenders;
I get an exception:
No qualifying bean of type 'java.util.HashMap'
@Autowired
private List<EmailSender> emailSenders;
It is interesting that whet I tried to change HashMap
to List
all worked fine, do you know how to correctly do that?
Solution
reposting saw303's comment as an answer so it's easier to find (I almost missed the comment until I reread the OP a second time)
Use a Map instead of a concrete HashMap – saw303 Dec 5 '17 at 19:28
Answered By - Adam
Answer Checked By - Clifford M. (JavaFixing Volunteer)