How to set Class<?> as property value in spring application context?
问题 Is there a way to configure spring application context so it will initialize the setter with value of type Class? I need to initialize that structure: Map<Class<?>, Object> 回答1: 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> 来源: