package com.javalec.springEx6_1;
import java.util.ArrayList;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ApplicationConfig {
@Bean
public Student student1(){
ArrayList<String> hobbys = new ArrayList<String>();
hobbys.add("수영");
hobbys.add("요리");
Student student = new Student("홍길동", 20, hobbys);
student.setHeight(180);
student.setWeight(80);
return student;
}
}
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<context:annotation-config />
<bean class="com.javalec.springEx6_1.ApplicationConfig" />
<bean id="student2" class="com.javalec.springEx6_1.Student">
<constructor-arg value="홍길순"></constructor-arg>
<constructor-arg value="30"></constructor-arg>
<constructor-arg >
<list>
<value>마라톤</value>
<value>요리</value>
</list>
</constructor-arg>
<property name="height" value="190" />
<property name="weight" value="70" />
</bean>
</beans>