【发布时间】:2023-04-11 06:28:02
【问题描述】:
我正在尝试注入两个具有不同注释的相同类型的 EJB。 但是注入的实例是一样的。
@Path("/some")
public class SomeResource {
@Inject
@SomePostConstructionAnnotationForSomeService("this")
private SomeService s1;
@Inject
@SomePostConstructionAnnotationForSomeService("that")
private SomeService s2;
}
SomeService 类如下所示。
public SomeService {
@PostConstruct
private void constructed() {
// find the annotation and do something else.
}
@Inject
private InjectionPoint injectionPoint;
}
问题是只调用了s1,而s2等于s1。
【问题讨论】: