@Bean

· 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(..
· Spring
이전 글에서 Autowired에 대한 포스팅을 했으니 읽고 오시면 이해하시기 쉽습니다. 굳이 읽지 않으시고 바로 보셔도 무방합니다. [Spring] @Autowired - 의존성 자동주입 Spring 프레임워크에서 @Autowired 어노테이션은 자동 의존성 주입을 강력한 도구로 사용됩니다. @Autowired을 통해 Spring은 Application Context에서 필요한 Bean을 찾아서 해당 필드에 주입합니다. 이를 통해 muscleking3426.tistory.com Spring에서 @Autowired 어노테이션은 일반적으로 Spring 컨테이너가 자동으로 빈을 주입할 때 사용됩니다. 그러나 때로는 특별한 경우에 수동으로 빈을 등록하고 주입할 때가 있습니다. 이번에는 @Autowired 어노테..
runnnerDevHong
'@Bean' 태그의 글 목록