Could not autowire. There is more than one bean of 'xxx' type.
Hi there,
I am using latest 12.1.1, and I get a RED mark error when I usecustom javax.inject.Qualifier extesion on mutliple injection types. Has anyone seen this?
How to reproduce:
1) Create two custom qualifiers:
import javax.inject.Qualifier;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Qualifier
public @interface MyQualifier1 {
}
import javax.inject.Qualifier;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)
@Qualifier
public @interface MyQualifer2 {
}
2) Now use it in 3 java source files:
import javax.annotation.Resource;
import javax.inject.Named;
// file: MyStuff1.java
@Named
@MyQualifier1
public class MyStuff1 implements MyStuff {
}
// file: MyStuff2.java
@Named
@MyQualifier2
public class MyStuff2 implements MyStuff {
}
// file: MyService.java
@Named
public class MyService {
@Resource
@MyQualifier1
private MyStuff myStuff1; // Intellij marked red error, but this code compiles and runs fine in a container.
}
Thanks,
-Zemian
Please sign in to leave a comment.