이것은 Spring documentation, 섹션 9.5.4에서 나온ProxyFactoryBean에서 ref로 프로토 타입 빈을 참조하는 Spring
<bean id="myAdvisor" class="com.mycompany.MyAdvisor">
<property name="someProperty" value="Custom string property value"/>
</bean>
<bean id="debugInterceptor"class="org.springframework.aop.interceptor.DebugInterceptor">
</bean>
<bean id="person"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces" value="com.mycompany.Person"/>
<property name="target" ref="personTarget"/>
<property name="interceptorNames">
<list>
<value>myAdvisor</value>
<value>debugInterceptor</value>
</list>
</property>
</bean>
이제 코드 아래 메모에 다음과 같이 표시됩니다.
빈 참조를 보유하지 마십시오. 그 이유는 ProxyFactoryBean의 singleton 속성을 false로 설정하면 가 독립 프록시 인스턴스를 반환 할 수 있어야합니다. 고문 중 하나가 자체 프로토 타입 인 경우 독립적 인 인스턴스 가 반환되어야하므로 팩토리에서 프로토 타입 의 인스턴스를 얻을 수 있어야합니다. 참조를 들고 있으면 충분하지 않습니다.
누군가이 방법을 설명해 주시겠습니까? 나는 다양한 범위를 안다. 고문이 프로토 타입 인 경우 새 인스턴스를 반환해야한다는 것을 알고 있습니다. 그러나 나는 마지막 진술 (굵게 강조 표시)을 얻지 못했습니다. ref="debugInterceptor"
를 지정하면 빈 작성 메커니즘이 변경됩니까? 콩을 ref
하면 싱글 톤 인스턴스가됩니다.