如何设置Class<?>作为Spring应用程序上下文中的属性值? [英] How to set Class<?> as property value in spring application context?
本文介绍了如何设置Class<?>作为Spring应用程序上下文中的属性值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种配置spring应用程序上下文的方法,以便它将初始化类型为Class的值的setter?
Is there a way to configure spring application context so it will initialize the setter with value of type Class?
我需要初始化该结构:Map<Class<?>, Object>
I need to initialize that structure: Map<Class<?>, Object>
推荐答案
您是否尝试过以下方法:
Have you tried something like this:
<bean id="myBean" class="myBean">
<!-- This will set a map onto the property classMap of myBean -->
<property name="classMap">
<map key-type="java.lang.Class">
<entry key="java.lang.String" value="A String keyed by the class 'java.lang.String'" />
</map>
</property>
</bean>
这篇关于如何设置Class<?>作为Spring应用程序上下文中的属性值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文