Spring@Autowired 설정

2529 단어 @Autowired
@Autowired 설정:
Spring 은 BeanPostProcessor 를 통 해@Autowired 를 분석 하기 때문에@Autowired 가 역할 을 하려 면 스프링 용기 에 미리 설명 해 야 합 니 다.
AutowiredAnnotationBeanPostProcessor Bean。
또는 암시 적 등록 사용(
암시 적 등록 post-processors 포함
AutowiredAnnotationBeanPostProcessor,CommonAnnotationBeanPostProcessor,PersistenceAnnotationBeanPostProcessor,RequiredAnnotationBeanPostProcessor。)

<?xml version="1.0" encoding="UTF-8"?>
<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-3.0.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
	default-lazy-init="true">

	<!--   BeanPostProcessor        @Autowired   Bean      -->
	<!-- <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" /> -->
		
	<!--        -->
	<context:annotation-config/>   

</beans>


@Autowired
private Scheduler scheduler;


<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"
	default-lazy-init="false">
	<!--     -->
	<bean
		name="scheduler"
		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<!--   applicationContextSchedulerContextKey    spring    -->
		<property name="applicationContextSchedulerContextKey">
			<value>applicationContext</value>
		</property>
	</bean>
</beans> 

좋은 웹페이지 즐겨찾기