春天:一个接收类列表的bean [英] spring: a bean that receives a list of Classes

查看:69
本文介绍了春天:一个接收类列表的bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Spring XML上下文中定义一个具有类型为类列表的属性的bean:即 List< Class<?>>。 classes

I want to define in my Spring XML context a bean that has a property of the type List of classes: i.e. List<Class<?>> classes

我如何向该bean发送许多类,例如java.lang.String和java.lang.Integer?

How do I send that bean a number of classes, say java.lang.String and java.lang.Integer?

该列表不需要可重用,即我不会在另一个bean中引用它。

The list needs not be reusable, i.e. I will not refer to it in another bean.

推荐答案

使用Spring,最简单的方法通常适用于.....

With Spring, the simplest possibility usually works.....

   <property name="classes">
      <list>
         <value>java.lang.String</value>
         <value>java.lang.Integer</value>
      </list>
   </property>

这篇关于春天:一个接收类列表的bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆