프로토타입 빈과 싱글톤 빈을 함께 사용 시 문제점 프로토 타입 빈과 싱글톤 빈을 함께 사용하면 의도한 대로 잘 동작하지 않을 수 있다. 아래 코드를 통해 알아보았다. 예제 아래 코드는 싱글톤 빈 내부에 있는 프로토타입 빈이 있을 때 2개의 클라이언트가 각각 싱글톤을 주입받으면 내부에 있는 프로토타입이 새로 생성되는지 알아보는 코드이다.public class SingletonWithPrototypeTest { @Test void singletonClientUsePrototype() { AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(ClientBean.class, ..
Java/Spring
2024. 9. 2. 15:22
