It seems to me that the following should result with both fields pointing the same instance,
class BeanToInject {
// something
}
class TargetBean {
@Inject
private BeanToInject first;
@Inject
private BeanToInject second;
}
But it seems not to be true, because sysouting first and second I get
first: BeanToInject@2f51cd27
second: BeanToInject@1e92abdf
Isn’t it so that beans’ references should be reused across given context?
What did I miss here?
You did not specify the scope of
BeanToInject, and CDI’s default scope is the dependent pseudo-scope where each injection point receives a new instance of the bean.