@Scope

· Spring
스프링 컨테이너는 빈 객체를 한 개만 생성합니다. 과연 그런지 한번 코드를 통해 알아볼까요? public class Main { public static void main(String[] args) { //1. 컨테이너 초기화 AbstractApplicationContext ctx = new AnnotationConfigApplicationContext(AppCtx3.class); //2. 빈 객체 로드 후, 사용하기 Client client = ctx.getBean(Client.class); Client client2 = ctx.getBean(Client.class); System.out.println("두 개의 객체가 같을까 ? : " + (client == client2)); client.send(..
runnnerDevHong
'@Scope' 태그의 글 목록