spring - In Grails, specifying which of two classes implementing the same interface should be used for injection -


in grails 2.5.0, there's grails class, let's call g, implements interface, let's call i; i've created new class myself, let's call m, implements i.

unfortunately, third-party grails plugin injects using:

@autowired i 

which throws nouniquebeandefinitionexception, because both g & m implement i, , grails doesn't know use.

how can specify injections of i, class g should used?

i want inject class m injections like:

def m 

or

m m 

some solutions mention using @qualifier annotation @ injection site, but, because injection site in third-party plugin, don't want modify code if can avoid it. shouldn't modify source of g, since grails itself. so, i'd prefer either configure in config file, or somehow annotate m such either isn't candidate i injection, or it's lower priority candidate i injection default priority, assume has been applied g.

i know must documented somewhere in grails and/or spring, it's i've gotten many spurious results searching answer.

a possibly simpler converse question how specify m should used injections of type i, instead of original question how specify m should not used injections of type i.

in grails-app/conf/spring/resources.groovy, add:

beans = {springconfig.addalias 'i', 'g'} 

Comments