2016-06-27 11 views
0

나는 spring.net을 사용하여 객체를 생성 할 때 문제점에 직면하고 있으며 그에 대한 해결책이 필요합니다.spring.net을 사용하여 TypeAliases에 대한 속성 주입을 수행하는 방법

설정 설명 : 다음과 같은 TypeAliases 구성 파일이 있습니다.

<objects xmlns="http://www.springframework.net" > 
    <object id="TypeAlias" type="Spring.Objects.Factory.Config.TypeAliasConfigurer, Spring.Core"> 
     <property name="TypeAliases"> 
      <dictionary>     
       <entry key="ABCHost" value-ref="XYZ"/> 
      </dictionary> 
     </property> 
    </object> 
    <object id="XYZ" type="ABC.ABCHost, ABCHost" > 
     <property name="Viewer" ref="ViewerFactory" /> 
    </object> 
</objects> 

왜 ObjectPoolFactory가 기본 생성자를 사용하기 때문에 속성 주입을 수행하고 있습니까? 개체 생성 중에이 뷰어 속성을 아래의 봄 파일을 통해 만들길 원합니다.

<object id="ViewerFactory" type="XYZViewerFactory, XYZViewer" singleton ="true"> 
    </object> 

문제 : 내가 전화가 ABCHost 클래스와 뷰어 속성의 생성자를 기본값으로 얻을 응용 프로그램을 실행하는 동안은 XYZViewer로 값을 가져옵니다. 그 후에 나는 봄 오류가 발생합니다 -

ServiceProvider.get_AppContext - ServiceProvider.cs(31) 
    Spring Error : 
Spring.Objects.Factory.ObjectInitializationException: 
------------------------------------ 
--- Message 
------------------------------------ 
Invalid value 'ABCHost' for custom type alias - must be a System.String or System.Type. 

------------------------------------ 
--- Stack Trace 
------------------------------------ 
    at Spring.Objects.Factory.Config.AbstractConfigurer.ResolveRequiredType(Object value, String errorContextSource, String errorContext) 

이 문제의 해결책을 찾는 데 도움을 줄 수 있습니까? 미리 감사드립니다.

답변

0

TypeAlias은 매우 간단한 XML 구성 OUTSIDE 봄/객체를 사용하여 정의됩니다 docs에서

<configuration> 

    <configSections> 
    <sectionGroup name="spring"> 
     <!-- other configuration section handler defined here --> 
     <section name="typeAliases" type="Spring.Context.Support.TypeAliasesSectionHandler, Spring.Core"/> 
    </sectionGroup> 
    </configSections> 

    <spring> 
    <typeAliases> 
     <alias name="WebServiceExporter" type="Spring.Web.Services.WebServiceExporter, Spring.Web"/> 
    </typeAliases> 
    </spring> 

</configuration> 

봐 더 볼 수 있습니다.

TypeAlias는 spring/typeAliases 구조체에 정의됩니다.