Student.java

package com.lgy.spring6_1;

import java.util.ArrayList;

public class Student {
	private String name; 
	private int age;
	private ArrayList<String> hobbys;
	private double height;
	private double weight;
	
	public Student(String name, int age, ArrayList<String> hobbys) {
		this.name = name;
		this.age = age;
		this.hobbys = hobbys;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public ArrayList<String> getHobbys() {
		return hobbys;
	}
	public void setHobbys(ArrayList<String> hobbys) {
		this.hobbys = hobbys;
	}
	public double getHeight() {
		return height;
	}
	public void setHeight(double height) {
		this.height = height;
	}
	public double getWeight() {
		return weight;
	}
	public void setWeight(double weight) {
		this.weight = weight;
	}
}

StudentInfo.java

package com.lgy.spring6_1;

public class StudentInfo {
	private Student student;
	
	
	
	public Student getStudent() {
		return student;
	}
	
	public void setStudent(Student student) {
		this.student = student;
	}
}

Family.java

package com.lgy.spring6_1;

public class Family {
	private String papaName;
	private String mamiName;
	private String sisterName;
	private String brotherName;
	
	public Family(String papaName, String mamiName) {
		super();
		this.papaName = papaName;
		this.mamiName = mamiName;
	}
	
	public String getPapaName() {
		return papaName;
	}
	public void setPapaName(String papaName) {
		this.papaName = papaName;
	}
	public String getMamiName() {
		return mamiName;
	}
	public void setMamiName(String mamiName) {
		this.mamiName = mamiName;
	}
	public String getSisterName() {
		return sisterName;
	}
	public void setSisterName(String sisterName) {
		this.sisterName = sisterName;
	}
	public String getBrotherName() {
		return brotherName;
	}
	public void setBrotherName(String brotherName) {
		this.brotherName = brotherName;
	}
	
}

applicationCTX1.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="<http://www.springframework.org/schema/beans>"
	xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
	xsi:schemaLocation="<http://www.springframework.org/schema/beans> <http://www.springframework.org/schema/beans/spring-beans.xsd>">
	<bean id="student1" class="com.lgy.spring6_1.Student">
		<constructor-arg value="홍길동"></constructor-arg>
		<constructor-arg value="18"></constructor-arg>
		<constructor-arg>
			<list>
				<value>수영</value>
				<value>요리</value>
			</list>

		</constructor-arg>
		<property name="height">
			<value>187</value>
		</property>
		<property name="weight">
			<value>84</value>
		</property>
	</bean>

	<bean id = "studentInfo" class="com.lgy.spring6_1.StudentInfo">
		<property name="student">
			<ref bean="student1"></ref>
		</property>
	</bean>
</beans>

applicationCTX2.xml

20230519161146.png

c와 p 체크!

applicationCTX2.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="<http://www.springframework.org/schema/beans>"
	xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
	xmlns:c="<http://www.springframework.org/schema/c>"
	xmlns:p="<http://www.springframework.org/schema/p>"
	xsi:schemaLocation="<http://www.springframework.org/schema/beans> <http://www.springframework.org/schema/beans/spring-beans.xsd>">
	<bean id="student3" class="com.lgy.spring6_1.Student">
		<constructor-arg value="홍길자"></constructor-arg>
		<constructor-arg value="8"></constructor-arg>
		<constructor-arg>
			<list>
				<value>줄넘기</value>
				<value>공기놀이</value>
			</list>

		</constructor-arg>
		<property name="height">
			<value>126</value>
		</property>
		<property name="weight">
			<value>21</value>
		</property>
	</bean>

	<bean id = "family" class="com.lgy.spring6_1.Family" c:papaName="홍아빠"  c:mamiName="홍엄마"
	 p:sisterName="홍누나" >
	 <property name="brotherName" value="홍오빠"></property>
		
	</bean>
</beans>