Allow to use @Named annotation without having to set the bean as @Primary
This commit is contained in:
committed by
Dave Syer
parent
afcc7dc371
commit
4597ba5af4
@@ -110,8 +110,14 @@ public class SpringModule implements Module {
|
||||
@Override
|
||||
public Object get() {
|
||||
if (this.result == null) {
|
||||
String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, this.type);
|
||||
if (names.length == 1) {
|
||||
|
||||
String[] named = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.beanFactory, this.type);
|
||||
List<String> names = new ArrayList<>(named.length);
|
||||
for (String name : named) {
|
||||
if (name.equals(this.name)) names.add(name);
|
||||
}
|
||||
|
||||
if (names.size() == 1) {
|
||||
this.result = this.beanFactory.getBean(this.name, this.type);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user