如何对具有不同属性的同一个类进行多个注释
我有以下配置。请建议如何在没有 xml 文件配置的情况下出于相同目的注释该类。
<bean id="validationBeanHelper" class="com.xxx.service.impl.ValidationBeanHelper">
<property name="fileDAO" ref="fileDAO"/>
<property name="unmarshaller" ref="castorMarshaller"/>
<property name="paymentMetricDAO" ref="paymentMetricDAO"/>
<property name="workflowManager" ref="workflowManager"/>
<property name="validationType" ref="DATA_VALIDATION"/>
<property name="validators">
<list>
<ref bean="tifDataValidator" />
</list>
</property>
</bean>
<bean id="postProcessingValidationBeanHelper" class="com.xxx.service.impl.ValidationBeanHelper">
<property name="fileDAO" ref="fileDAO"/>
<property name="paymentMetricDAO" ref="paymentMetricDAO"/>
<property name="workflowManager" ref="workflowManager"/>
<property name="validationType" ref="POST_PROCESSING_VALIDATION"/>
<property name="validators">
<list>
<ref bean="tifToleranceValidator" />
</list>
</property>
</bean>
I have following configuration. Please suggest how to annotate that class for the same purpose without xml file configuration.
<bean id="validationBeanHelper" class="com.xxx.service.impl.ValidationBeanHelper">
<property name="fileDAO" ref="fileDAO"/>
<property name="unmarshaller" ref="castorMarshaller"/>
<property name="paymentMetricDAO" ref="paymentMetricDAO"/>
<property name="workflowManager" ref="workflowManager"/>
<property name="validationType" ref="DATA_VALIDATION"/>
<property name="validators">
<list>
<ref bean="tifDataValidator" />
</list>
</property>
</bean>
<bean id="postProcessingValidationBeanHelper" class="com.xxx.service.impl.ValidationBeanHelper">
<property name="fileDAO" ref="fileDAO"/>
<property name="paymentMetricDAO" ref="paymentMetricDAO"/>
<property name="workflowManager" ref="workflowManager"/>
<property name="validationType" ref="POST_PROCESSING_VALIDATION"/>
<property name="validators">
<list>
<ref bean="tifToleranceValidator" />
</list>
</property>
</bean>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能。
@Service
和@Inject
等注释假定只为该类定义了一个 bean。在你的情况下,你需要两颗豆子。如果你不需要xml,你可以使用 java-config,但前提仍然是:你有两个 bean,所以你必须手动连接它们。
You can't.
Annotations like
@Service
and@Inject
assume that there is only one bean defined for that class. And in your case you need two beans.If you don't want xml, you can use java-config, but the premise remains: you have two beans, so you have to manually wire them.