> For the complete documentation index, see [llms.txt](https://heunnajo.gitbook.io/spring/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://heunnajo.gitbook.io/spring/undefined-4/xml.md).

# 다양한 설정 형식 지원 - 자바, xml

스프링 컨테이너는 다양한 형식의 설정 정보를 받아들일 수 있게 유연하게 설계되어 있다.\
자바코드, XML, Groovy 등등

![](blob:https://app.gitbook.com/f033fd90-9efc-4962-9dc9-3928d41214c3)

최근에는 스프링 부트를 많이 사용하면서 XML기반의 설정은 잘 사용하지 않는다. 하지만 아직 많은 레거시 프로젝 트 들이 XML로 되어 있고, 또 XML을 사용하면 **컴파일 없이 빈 설정 정보를 변경할 수 있는 장점**도 있으므 로 한번쯤 배워두는 것도 괜찮다.

애노테이션 기반 자바 코드 설정 Appconfig 처럼 1:1로 하나씩 빈에 등록하는 것이 똑같다. 한가지 추가되는 것이 있다면 생성자를 넣어줘야한다. \<constructor-arg ...>

**GenericXmlApplictionContext** 를 사용하면서 xml 설정 파일을 넘기면 된다.

```markup
<?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="memberService" class="hello.core.member.MemberServiceImpl">
          <constructor-arg name="memberRepository" ref="memberRepository" />
      </bean>
      <bean id="memberRepository"
  class="hello.core.member.MemoryMemberRepository" />
      <bean id="orderService" class="hello.core.order.OrderServiceImpl">
          <constructor-arg name="memberRepository" ref="memberRepository" />
          <constructor-arg name="discountPolicy" ref="discountPolicy" />
      </bean>
      <bean id="discountPolicy" class="hello.core.discount.RateDiscountPolicy" />
  
 </beans>
```
