2016-06-27 7 views
0

私はspring.netを使用してオブジェクトを作成する際に問題に直面しており、その解決策が必要です。spring.netを使用して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がデフォルトのコンストラクタを使用するため、プロパティ注入を行っているのですか?オブジェクトの作成中に、私はこのViewerプロパティをSpringの下のファイルから作成します。

<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構造体で定義されています。

関連する問題