Объявление Spring для интерфейсов с той же реализацией

У меня проблема с Весной.

У меня есть два отдельных интерфейса: findUnconditionalDiscountValuesStrategy и findConditionalDiscountValuesStrategy. Эти интерфейсы реализованы в одном классе MmfgFindPricingWithCurrentPriceFactoryStrategy.

Это объявлено в файле конфигурации spring следующим образом:

<alias name="mmfgFindPricingWithCurrentPriceFactoryStrategy" alias="currentFactoryFindPricingStrategy"/>
<bean id="mmfgFindPricingWithCurrentPriceFactoryStrategy" class="com.mmfg.mmfgacceleratorcore.order.strategies.calculation.impl.MmfgFindPricingWithCurrentPriceFactoryStrategy" parent="abstractBusinessService">
    <property name="findPricingWithCurrentPriceFactoryStrategy" ref="original-currentFactoryFindPricingStrategy"/>
    <property name="configurationService" ref="configurationService"/>
    <property name="mmfgSessionService" ref="mmfgSessionService"/>
    <property name="mmfgUtilsDao" ref="mmfgUtilsDao" />
</bean>

Теперь я использую два интерфейса в классе

private FindUnconditionalDiscountValuesStrategy findUnconditionalDiscountValuesStrategy;
private FindConditionalDiscountValuesStrategy findConditionalDiscountValueStrategy;

с геттером и сеттером (геттер protected и сеттер @Required).

Теперь я объявил этот класс таким образом в файле конфигурации spring:

<bean id="mmfgOrderCalculationStrategy" class="com.mmfg.mmfgacceleratorcore.order.strategies.calculation.impl.DefaultMmfgOrderCalculationStrategy">
    <property name="findUnconditionalDiscountValuesStrategy" ref="currentFactoryFindPricingStrategy"/>
    <property name="findConditionalDiscountValuesStrategy" ref="currentFactoryFindPricingStrategy"/>
    <property name="modelService" ref="modelService" />
    <property name="commonI18NService" ref="commonI18NService" />
    <property name="calculationService" ref="calculationService"/>
</bean>

ссылка одинакова для двух интерфейсов, потому что класс реализации одинаков.

Но во время выполнения я получаю эту ошибку:

org.springframework.beans.factory.BeanInitializationException: свойство findConditionalDiscountValueStrategy требуется для bean-компонента mmfgOrderCalculationStrategy

Как мне объявить ref в двух свойствах?


person sharkbait    schedule 05.08.2015    source источник
comment
опечатка - ваше свойство называется findConditionalDiscountValueStrategy (значение, а не значения) в вашем классе, но вы пытаетесь установить его как findConditionalDiscountValuesStrategy (значения)   -  person Vladimir    schedule 05.08.2015
comment
Вы правы :( я курица..........   -  person sharkbait    schedule 05.08.2015
comment
если вы напишете это в ответе, я приму это   -  person sharkbait    schedule 05.08.2015


Ответы (1)


Есть опечатка. Мое свойство называется findConditionalDiscountValueStrategy. Но в классе это имя findConditionalDiscountValuesStrategy.

person sharkbait    schedule 05.08.2015