XML 설정 파일 포맷

기본 포맷

빈 등록 및 빈 설정을 모두 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">

</beans>

어노테이션 설정을 사용하기 위한 포맷

빈 등록은 XMl, 빈 설정은 자바 어노테이션으로 할 경우 이 포맷을 사용한다.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       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 
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:annotation-config/>
</beans>

빈(Bean) 설정 예시

<bean> 태그를 이용해 빈을 정의한다. <bean> 태그의 필수 속성은 class 하나 뿐이다.

<bean id="studentDao" class="ems.member.dao.StudentDao" />

자동 주입 설정 - autowire 속성

autowire=”byName”