There is one solution:
<bean name="1" class="My1" />
<bean name="2" class="My2" scope="prototype">
<property name="field1" ref="1">
</bean>
<bean name="3" class="My3" scope="prototype">
<property name="field1" ref="1">
</bean>
But I don’t want to do that. I don’t want that bean “1” is accessible everywhere in the application and Spring controls it. I only want that bean “2” and “3” get the same instance. Can I achieve that? How?
I’m not really sure what the issue is. By default, Spring beans are singletons. So in your example,
2and3already have the same instance of1. The Spring-controlled instance of1is not really “accessible everywhere in the application”, it’s only accessible where it’s been injected.