<?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-3.2.xsd">
<!--
scope 속성
prototype : 객체 호출 시 매번 다른 객체 생성
singleton : 객체 호출 시 하나만 생성해서 돌려씀(default)
-->
<!--
index 속성
인자의 순서를 지정(0부터)
type 속성
해당 값의 타입을 명시
-->
<!--
c namespace : constructor 설정
p namespace : property 설정
-->
<bean id="mbean" class="pack.MessageImpl"
scope="prototype"
c:year="2000"
c:myInfo-ref="info"
p:spec="스프링 전문가"
p:inter-ref="outFileInterImpl">
<!-- 생성자 constructor 주입 -->
<!--
<constructor-arg index="1">
<value>안녕하숑</value>
</constructor-arg>
<constructor-arg index="0">
<value>반가워요</value>
</constructor-arg>
-->
<constructor-arg index="0" type="java.lang.String" value="안뇽"/>
<constructor-arg index="1" type="String" value="방가"/>
<!-- 속성 property 주입 -->
<property name="myInfo">
<!-- 다른 설정 파일의 bean 호출 가능
<ref bean="info"/>
-->
<!--
local : 현재 설정 파일의 bean 만 호출 가능
-->
<ref local="kbs"/>
</property>
</bean>
<bean id="info" name="kbs" class="pack.MyInfo" scope="prototype"/>
<bean id="outFileInterImpl" class="other.OutFileInterImpl">
<property name="filePath" value="c:/test.txt"/>
</bean>
</beans>
'spring > 기초' 카테고리의 다른 글
property injection 속성 주입 (0) | 2014.05.02 |
---|---|
constructor injection 생성자 주입 (0) | 2014.05.02 |
스프링 컨테이너 (0) | 2014.04.30 |