【发布时间】:2016-10-29 01:06:15
【问题描述】:
我在使用 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 使用默认构造函数。在创建对象时,我希望通过下面的 spring 文件创建这个 Viewer 属性。
<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)
您能帮忙找到这个问题的解决方案吗?提前致谢。
【问题讨论】:
-
找到任何解决方案了吗?
标签: c# spring.net