在spring-integration.xml中指定我的bean的哪种方法更好?
我有两种不同的方式来声明spring集成bean。他们两个似乎都工作。我使用的是基于Eclipse的Spring STS IDE 这样:在spring-integration.xml中指定我的bean的哪种方法更好?,spring-integration,javabeans,spring-bean,Spring Integration,Javabeans,Spring Bean,我有两种不同的方式来声明spring集成bean。他们两个似乎都工作。我使用的是基于Eclipse的Spring STS IDE 这样: <bean id="int-ftp:request-handler-advice-chain" class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice"> <property n
<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>
哪种方法更好?对于目标
这没关系。正如您已经注意到的,它工作得很好
唯一的区别是第二个声明是嵌套的,最后一个bean仅在
上下文中可见
第一个定义是顶级全局bean,它随处可见,也可以从其他bean重用
您可以在中找到有关内部bean的更多信息