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 |
Tags
- Container
- spring5
- #페이지이동
- 데이터 공유
- servlet
- 확장자 사라짐
- Servelt
- Spring
- ServletContextListener
- 서블릿 초기화 파라미터
- 점사라짐
- spring security
- 서블릿
- @PathVariable
- servletContext
- oauth
- 한글 처리
- 디자인패턴
- MVC
- #sendRedirect()
- Spring Boot
- 웹 어플리케이션 감시
- #jsp
- tomcat
- #java
- ServletConfig
- jsp
Archives
- Today
- Total
Choi의 고유결계
Spring - XML파일에 JAVA파일 포함시켜 적용하기 본문
반응형
XML파일에 JAVA파일 포함시켜 적용하기
오늘 배워 볼것은 XML 파일을 하나의 XML파일에 적용하는 방법입니다.
mongoContext.java
@Configuration
public class Application {
@Bean
public CustomerService customerService() {
return new CustomerService();
}
@Bean
public OrderService mongoService() {
return new mongoService();
}
}
root-context.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>
mongoContext.java 파일을 root-context.xml 에 import 해보겠습니다.
<?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">
<context:annotation-config/>
<bean class="mongoContext"/>
</beans>
한줄 추가로 xml 파일에 java로 작성한 설정파일을 포함시켰습니다.
<context:annotation-config/>
<bean class="mongoContext"/>
바로 이 스크립트 부분이 파일을 임포트하는 스크립트입니다.
context:annotation-config 를 먼저 쓰고,
기존과 같이 포함시킬 java 파일일 bean 태그로 생성해줍니다.
반응형
'Spring' 카테고리의 다른 글
Spring - 의존객체 자동 주입 (0) | 2019.03.09 |
---|---|
Spring - JAVA 설정 파일에 XML파일 적용하기 (0) | 2019.03.04 |
Spring - XML파일 import 하여 적용하기 (0) | 2019.03.04 |
Spring - 다양한 의존 객체 주입방법 (0) | 2019.03.02 |
Spring - DI(Dependency Injection) (0) | 2019.02.24 |
Comments