Post a Job  |   Ask a Question?   |   Already registered? login or register
Mamatha Reddy
19/04/2016 01:52 PM

collection dependency injection but i did get this by the constructo injection please anyone can tel me is there any mistake in this program i did get outpu


Spam    7 Comments

Mamatha,Reddy
19/04/2016 13:53:52
plz any one can identify mistake please send me

RajaChandra,Boppana
19/04/2016 14:22:28
Specify bean the following way

RajaChandra,Boppana
19/04/2016 14:22:41

venkat,korimi
19/04/2016 14:58:37
Declare two parameteriszed constructor in Course class like this @ConstructorProperties({"subjects","faculty"}) public Course(List<String> subjects,Set<String> faculty){ this.subjects=subjects; this.faculty=faculty; } Declare bean like this in spring cfg file <bean id="btechcse" class="com.cdpInj.beans.Course"> <constructor-arg name="subjects"> <list value-type="java.lang.String"> <value>C</value> <value>D.S</value> <value>M1</value> </list> </constructor-arg> <constructor-arg name="faculty"> <set value-type="java.lang.String"> <value>Padmaja</value> <value>Jadav</value> <value>Madhav</value> </set> </constructor-arg> </bean> why because u have declare multiple constructor in class also it will only one based on the max parameters and order

venkat,korimi
19/04/2016 15:00:42
<bean id="btechcse" class="com.cdpInj.beans.Course"> <constructor-arg name="subjects"> <list value-type="java.lang.String"> <value>C</value> <value>D.S</value> <value>M1</value> </list> </constructor-arg> <constructor-arg name="faculty"> <set value-type="java.lang.String"> <value>Padmaja</value> <value>Jadav</value> <value>Madhav</value> </set> </constructor-arg> </bean>

venkat,korimi
19/04/2016 15:01:25
@ConstructorProperties({"subjects","faculty"}) public Course(List<String> subjects,Set<String> faculty){ this.subjects=subjects; this.faculty=faculty; }

Nagarjuna,Reddy
20/04/2016 15:40:39
public class College { private Map<String, String> hodtocoursemap; <map key-type="java.lang.String" value-type="java.lang.String"> <entry key="k1" value-ref="course"></entry> </map> here in this case we should not give value-ref="course" (it is an object) but in private Map<String, String> hodtocoursemap; specified as the String as generic type <props> <prop key="k2"> "sri"></prop> <prop key="k3"> "rama"</prop> </props> dont give "sri" in double quotes anyway it is going to take as a String in properties otherwies in output we will get double quotes

Languages :
xml