Spring: a bean that gets a list of classes

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

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

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

+6
java spring dependency-injection inversion-of-control
source share
2 answers

The easiest option usually works with Spring ...

  <property name="classes"> <list> <value>java.lang.String</value> <value>java.lang.Integer</value> </list> </property> 
+15
source share
 <property name="classes"> <list> <bean class="java.lang.Class" factory-method="forName"> <constructor-arg value="java.lang.String"/> </bean> </list> </property> 

Something like that...

+1
source share

All Articles