스프링
annotation
y00ns00
2020. 5. 18. 16:20
종류가 굉장히 많다.
@Autowired
- 필요한 곳에 자동으로 묶기 => xml에 새로운 bean 필요 => main에 factory도 바꿔주어야함
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"></bean>
public static void main(String[] args) {
// BeanFactory factory =
// new XmlBeanFactory(new FileSystemResource("src/app.xml"));
ApplicationContext context =
new ClassPathXmlApplicationContext("app.xml");
Greetingimple gr = context.getBean("gi", Greetingimple.class);
gr.printMsg();
}
의존 자동 설정
@AutoWired : 스프링전용 - 연결 : 타입에 맞춰서 연결
@Injection : 자바에서 지원 - 연결 : 타입에 뭦춰서 연결
@Resource : 자바에서 지원 - 연결 : 이름으로 연결