2016-06-02 4 views
1

스프링 통합 빈을 선언하는 두 가지 다른 방법이 있습니다. 그들은 둘 다 작동하는 것 같습니다. Spring STS Eclipse 기반 IDE를 사용하고 있습니다.spring-integration.xml에서 콩을 지정하는 방법은 어느 것이 좋습니까?

이 방법 :

<bean id="int-ftp:request-handler-advice-chain" 
     class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"> 
     <property name="trapException" value="true"></property> 
     <property name="onFailureExpression" value="#root"></property> 
     <property name="failureChannel" ref="errorChannel"></property> 
</bean> 

또는 이러한 방법 :

<int-ftp:request-handler-advice-chain> 
    <bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"> 
     <property name="trapException" value="true" /> 
     <property name="onFailureExpression" value="#root" /> 
     <property name="failureChannel" ref="errorChannel" /> 
    </bean> 
</int-ftp:request-handler-advice-chain> 

어느 쪽이 더 나은 무엇입니까?

답변

2

대상이 <int-ftp:outbound-gateway> 인 경우 중요하지 않습니다. 이미 잘 알고 있듯이 잘 작동합니다.

두 번째 선언이 인 경우 차이가이고 중첩 된 빈은 <int-ftp:request-handler-advice-chain> 컨텍스트에서만 볼 수 있습니다.

첫 번째 정의는 어디에서나 볼 수 있으며 다른 bean에서도 재사용 할 수있는 최상위 글로벌 bean입니다.

Spring Framework에서 내부 과자에 대한 자세한 정보를 찾을 수 있습니다.