In Grails 2.5.0, there's Grails class, let's call it
G, that implements a certain interface, let's call it
I; I've also created a new class myself, let's call it
M, that also implements
Unfortunately, a third-party Grails plugin injects using:
@Autowired I i
which throws a
NoUniqueBeanDefinitionException, because both
I, and Grails doesn't know which to use.
How can I specify that for all injections of
G should be used?
I only want to inject class
M for injections like:
Some solutions mention using an
@Qualifier annotation at the injection site, but, because the injection site is in a third-party plugin, I don't want to modify that code if I can avoid it. I also shouldn't modify the source of
G, since it is from Grails itself. So, I'd prefer either to configure this in some config file, or to somehow annotate
M such that it either isn't a candidate for
I injection, or that it's a lower priority candidate for
I injection than default priority, which is what I assume has been applied to
I know that this must be documented somewhere in Grails and/or Spring, it's just that I've gotten many spurious results searching for an answer.
A possibly simpler converse question is how to specify that
M should be used for injections of type
I, instead of my original question about how to specify that
M should not be used for injections of type