2017-06-02 3 views
3

を無効にしようとするとAliasを使用します。hybrisをオーバーライドするcommonI18NService roundCurrencyメソッド

私はオーバーcommonI18NService

OOTB定義

<alias alias="commonI18NService" name="defaultCommonI18NService"/> 
<bean id="defaultCommonI18NService" class="de.hybris.platform.servicelayer.i18n.impl.DefaultCommonI18NService" parent="abstractBusinessService"> 
    <property name="languageDao" ref="languageDao"/> 
    <property name="currencyDao" ref="currencyDao"/> 
    <property name="countryDao" ref="countryDao"/> 
    <property name="regionDao" ref="regionDao"/> 
    <property name="conversionStrategy" ref="conversionStrategy"/> 
</bean> 

roundCurrency方法当社のカスタムコード乗りたい: -

public class DefaultCustomCommonI18NService extends DefaultCommonI18NService 
{ 

    @Override 
    public double roundCurrency(double value, int digits) 
    { 
     // custom logic 
     return value; 
    } 
} 

注入するカスタム豆: -

<alias alias="commonI18NService" name="defaultCustomCommonI18NService"/> 
<bean id="defaultCustomCommonI18NService" class="com.extended.service.impl.DefaultCustomCommonI18NService" parent="defaultCommonI18NService"/> 

しかし、それはdefaultConverterRegistryのオートワイヤリング戦略はbyTypeあるので、これが起こっている

INFO [localhost-startStop-1] [HybrisContextFactory] Loading <<application>> spring config <master> from extension (saporderexchangeb2b) located in (saporderexchangeb2b-spring.xml) took: (121.4 ms) 
WARN [localhost-startStop-1] [CloseAwareApplicationContext] Exception encountered during context initialization - cancelling refresh attempt 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'listMergeBeanPostProcessor': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commercePlaceOrderMethodHooksListMergeDirective' defined in class path resource [b2bapprovalprocess-spring.xml]: Cannot resolve reference to bean 'b2bApprovalBusinessProcessCreationPlaceOrderMethodHook' while setting bean property 'add'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'b2bApprovalBusinessProcessCreationPlaceOrderMethodHook' defined in class path resource [b2bapprovalprocess-spring.xml]: Cannot resolve reference to bean 'defaultB2BCreateOrderFromCartStrategy' while setting bean property 'businessProcessCreationStrategy'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultB2BCreateOrderFromCartStrategy' defined in class path resource [b2bapprovalprocess-spring.xml]: Cannot resolve reference to bean 'cloneAbstractOrderStrategy' while setting bean property 'cloneAbstractOrderStrategy'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCloneAbstractOrderStrategy' defined in class path resource [order-spring.xml]: Cannot resolve reference to bean 'typeService' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultTypeService' defined in class path resource [servicelayer-spring.xml]: Cannot resolve reference to bean 'converterRegistry' while setting bean property 'converterRegistry'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'defaultConverterRegistry' defined in class path resource [servicelayer-spring.xml]: Unsatisfied dependency expressed through bean property 'commonI18NService': : No qualifying bean of type [de.hybris.platform.servicelayer.i18n.CommonI18NService] is defined: expected single matching bean but found 2: defaultCommonI18NService,defaultcustomCommonI18NService; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [de.hybris.platform.servicelayer.i18n.CommonI18NService] is defined: expected single matching bean but found 2: defaultCommonI18NService,defaultcustomCommonI18NService 
     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:136) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1566) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE] 

答えて

1

サーバーの起動時に例外をスロー:

が故に commonI18NServicedefaultCommonI18NServicedefaultcustomCommonI18NServiceための2つの候補を見つけ意味
<bean id="defaultConverterRegistry" ... autowire="byType" > 

どのものを注入するか分からない。

私はあなたの defaultcustomCommonI18NService主要Beanが primary="true"を使用してautowiredことができるようにすることを提案

see

<bean id="defaultCustomCommonI18NService" class="com.extended.service.impl.DefaultCustomCommonI18NService" parent="defaultCommonI18NService" primary="true" /> 
+0

はどのように見つけるか 'defaultConverterRegistry'は、問題を引き起こしていますか?私はそのクラスのソースを見ることができません。 'defaultConverterRegistry'がcommonI18NServiceを@Autowiredとした場合、 – HybrisFreelance

+1

はここに宣言されています:... \ hybris \ bin \ platform \ ext \ core \ resources \ servicelayer-spring.xmlそしてスタックトレースには –

+0

が表示されます。 DefaultModelConverterRegistry.classのソースには、Javaデコンパイラを使用する必要があります。 –

関連する問題