Spring annotation 기반 설정
@Required
필수 속성 지정
RequiredAnnotationBeanPostProcessor 등록 또는 <context:annotation-config/>
@Autowired
AutowiredAnnotationBeanPostProcessor 등록 또는 <context:annotation-config/>
멤버필드나 메서드에 선언
@Autowired(required=false)
@Autowired
@Qualifier("main")
빈객체의 수식어는 <qualifer>태그를 이용해 지정.
<bean>
<qualifier value="main'/>
</bean>
@Autowired
publid void init(@Qulifier("testJob") Job job, Task task)
@Resource
@Resource(name="beanId")
메서드나 멤버객체에 다사용
CommonAnnotationBeanPostProcessor 혹은 <context:annotation-config/>
@PostConstruct @PreDestroy
CommonAnnotationBeanPostProcessor 혹은 <context:annotation-config/>
@Component
<context:component-scan
base-package="com.nhncorp.smon.filemgr.action">
<context:include-filter type="regex" expression=".*TestJob"/>
<context:exclude-filter type="aspectj" expression="..*Task"/>
<context:component-scan>
@Autowired나 @Required도 함께 사용가능
@Component("testJob")
@Scope("prototype")
@Component
filter의 type은 annotation, assignable, regex, asjpectj
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
History
Last edited on 12/03/2009 11:51 by benelog
Comments (0)