annotation2 [Spring] Spring의 대표적인 Annotation 정리 Annotation 이란 ? 클래스와 메소드에 추가하여 다양한 기능을 부여하는 역할 코드량 감소, 쉬운 유지보수, 생산성 증가 대표적인 Annotation @Component 개발자가 생성한 Class를 Spring의 Bean 으로 등록할 때 사용 @Component(value="myman") public class Man { public Man() { System.out.println("hi"); } } @ComponentScan 말그대로 component들을 스캔해주는 어노테이션 SpringFramework는 @Component, @Service, @Repository, @Controller, @Configuration 중 1개라도 등록된 클래스를 찾으면 Context에 bean으로 등록 @Bean .. 2022. 4. 20. [Spring] Spring Bean 이란? Bean 이란? Spring IoC 컨테이너가 관리하는 자바 객체 객체들을 관리한다는 것은 개발자가 아닌 컨테이너가 객체의 생성부터 소멸까지의 생명주기(LifeCycle) 관리를 한다는 것 → 개발자들은 로직에 집중할 수 있음. new 연산자로 생성했을 때의 빈이 아닌 ApplicationContext.getBean( )으로 얻어질 수 있다 → 즉, Spring에서의 빈은 ApplicationContext가 만들어서 그 안에 담고 있는 객체 SampleController sampleController = new SampleContraoller(); -> Bean 객체 X SampleController bean = applicationContext.getBean(SampleController.class);.. 2022. 4. 18. 이전 1 다음