开发者

How to set Class<?> as property value in spring application context?

开发者 https://www.devze.com 2023-03-28 14:22 出处:网络
Is there a way to configure spring application context so it will initialize the setter with value of type Class?

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:开发者_JAVA百科 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>
0

精彩评论

暂无评论...
验证码 换一张
取 消