ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to inject List<String> values using a spring framework?

user-image
تم إضافة السؤال من قبل محمد حسام الدين حسن صدقى , Senior Functional Consultant , Egabi Fsi
تاريخ النشر: 2016/12/03
MOHAMMAD Sahwan
من قبل MOHAMMAD Sahwan , It Solution Expert , Siemens Energy

in Spring bean configuration file inside the bean write one property tag

<bean>

<property list="">

<llist>

</list>

</bean>

Mahesh Asutkar
من قبل Mahesh Asutkar , Java Web Developer , Accenture Solution

in the spring bean we can autowired and by help of xml conf. file inject the list elements, dependency injection feature of spring need to use.

<Bean id=""  >

<property value="" />

<list>

.........

</list>

</bean>

charan teegala
من قبل charan teegala , Product Engineer , EZDI

By Using Spring IOC Dependency Injection

<property ------->

<list -->

---------

</list>

</property>

Arka Dey
من قبل Arka Dey , Software Engineer , Softtek India Pvt Ltd

Inside Spring configuraton file where we will use bean configuration inside bean tag.

<bean>

<list>  

<value></value>  

</list> 

</bean>

KUMAR KUNAL
من قبل KUMAR KUNAL , Java Technical Lead, Technical Architect , D4 Insight for Ahli United Bank

xml configuration for injecting(DI) List into the spring bean.

ex - <util:list id="" value-type="java.lang.String"><value></value></util:list>

sangeetha Karepa
من قبل sangeetha Karepa

using spring dependency injection with property name of list

 

Venkata Naga Durga Prasad Grandhi
من قبل Venkata Naga Durga Prasad Grandhi , Java Developer , Green Buds Software Technologies

<PROPERTY NAME="list">

<LIST>

<VALUE>GVO</VALUE>

<VALUE>GVP</VALUE>

</LIST>

</PROPERTY>

Anuj  kumar
من قبل Anuj kumar

TO   INJECT LIST<STRING> INTO SPRING W HAV TO USE <LIST> TAG IN XML FILE WHIH IS SUB ELEMENT OF <PROPERTY> TAG AND <CONSTRUCTOR-ARG> TGA

SEE:

<PROPERTY NAME="A">

<LIST>

<VALUE>ANUJ SINGH</VALUE>

<VALUE>POOJA SINGH</VALUE>

</LIST>

</PROPERTY>

HERE PROPERTY NAME IS NAME OF LIST LIKE:LIST<STRING>A

NOW AT A[0]=ANUJ SINGH

A[1]=POOJA SINGH

list.of.strings=first,second,third took from properties file for e.g.

Then using SpEL:

 @Value("#{'${list.of.strings}'.split(',')}") 

 private List<String> list;

Ankit Sodani
من قبل Ankit Sodani , Manager , Ultratech Cement LTD

In XML we can use <util:list id="myList" value-type="java.lang.String">

 

Dionifer Canabano
من قبل Dionifer Canabano , Programmer / Analyst , Banco De Oro Inc. (BDO)

Add Collection dependency injection in the spring servlet.xml

المزيد من الأسئلة المماثلة