반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- AWS
- BeautifulSoup
- pandas
- lombok
- pds
- sklearn
- 자바
- Intellij
- 웹앱
- regressor
- BS
- SOUP
- java
- 크롤링
- 정처기
- APPEND
- Req
- 정보처리기사
- 정보처리기사필기
- springboot
- javascript
- 자바스크립트
- ensemble
- crawling
- request
- 머신러닝
- 비전공자
- 백준
- list
- dataframe
Archives
- Today
- Total
No sweet without sweat
GenericXMLApplicationContext 본문
728x90
반응형
GenericXMLApplicationContext
- 최근에 스프링 부트를 많이 사용하면서 XML기반의 설정을 잘 안씀
- 아직 많은 레거시 프로젝트 들이 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">
<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>
XmlAppContext
package hello.core.xml;
import hello.core.member.MemberService;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import static org.assertj.core.api.Assertions.assertThat;
public class XmlAppContext {
@Test
void xmlAppConfig(){
ApplicationContext ac = new GenericXmlApplicationContext("appConfig.xml");
MemberService memberService = ac.getBean("memberService", MemberService.class);
assertThat(memberService).isInstanceOf(MemberService.class);
}
}
728x90
반응형
'JAVA' 카테고리의 다른 글
[백준/10430] 자바 나머지 구하기 (0) | 2023.01.04 |
---|---|
[자바/java] 효율적인 배열 복사 System.arrayCopy (0) | 2022.08.20 |
스프링 빈 설정 메타 정보 - BeanDefinition (추상화) (0) | 2022.07.26 |
좋은 객체 지향 설계의 5가지 원칙(SOLID) (0) | 2021.12.21 |
IT교육 일기 JAVA [이클립스(Eclipse)] - else if, case (0) | 2021.12.20 |
Comments