I have class Student. It has two properties which are name and reference
so
<bean id="student" class="com.demo.student">
<property name="name" value="Student1">
<property name="Course" ref="Course">
</bean>
<bean id="Course" class="com.demo.Course">
<property name="workerClass" value="com.xyz.WorkerClass">
</bean>
this is working perfect but now my task is to create this above bean dynamically for example
i have comma separated list from properties file
listofstudent=studen1,student2,student3
now i have to create above student bean by reading listofstudent so student1 value should go into property name in student bean like that student2 and student 3
so basically i have to iterate list and for each value of list need to create bean.
<bean id="student" class="com.demo.student">
<property name="name" value={listofstudent.index(0)}>
<property name="Course" ref="Course">
</bean>
so each time this index should be incremented to read another value is there any way to do this
Note
i tried by creating @Bean of above bean i have also reading the list of values from properties file
i tried by creating another bean method annotated with @Bean and in that i am creating list of Student but it is not initialize the another bean then which is Course bean
Aucun commentaire:
Enregistrer un commentaire