는 다음과 같은 클래스를 고려봄은 프로토 타입 빈 confiusion
@Component
@Scope(scopeName = "prototype", proxyMode = ScopedProxyMode.TARGET_CLASS)
class PrototypeBean
{
public void method1() { ... };
public void method2() { ... };
}
@Component
public class SingletonBean
{
@Autowired
private PrototypeBean prototypeBean;
public void SingletonBean doSomething()
{
prototypeBean.method1();
prototypeBean.method2();
}
}
을 지금, 나는 그 때마다 해봐요() 메소드가 호출되는 새로운 PrototypeBean 인스턴스가 생성 SingletonBean에 주입 기대. 그러나 실제로 발생하는 것은 새로운 PrototypeBean 인스턴스가 만들어지고 method1()과 method2()를 호출 할 때 SingletonBean에 삽입됩니다.
나는 왜 이렇게까지 일 했어야했는지는 모르겠다. 걱정된다. 내가 틀렸다면 제발 정정하십시오.
오, 확인. doSomething 메서드가 호출 될 때마다 새 인스턴스가 만들어 질 것이라는 확신이 들었습니다. 그럼, 해결 방법을 찾아야 만하는 것 같습니다. – wookie