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
- jsp
- servletContext
- ServletContextListener
- Servelt
- ServletConfig
- #sendRedirect()
- spring security
- 웹 어플리케이션 감시
- 데이터 공유
- #jsp
- 확장자 사라짐
- 한글 처리
- spring5
- Container
- servlet
- MVC
- Spring Boot
- 서블릿 초기화 파라미터
- @PathVariable
- 점사라짐
- #페이지이동
- tomcat
- #java
- 서블릿
- 디자인패턴
- oauth
- Spring
Archives
- Today
- Total
Choi의 고유결계
Spring - JAVA 설정 파일에 XML파일 적용하기 본문
반응형
JAVA 설정 파일에 XML파일 적용하기
오늘 배워 볼것은 XML 파일을 하나의 XML파일에 적용하는 방법입니다.
mongoApp.java
@Configuration
public class Application {
@Bean
public CustomerService customerService() {
return new CustomerService();
}
@Bean
public OrderService mongoService() {
return new mongoService();
}
}
mongoContext.xml
<beans
<!-- mongo -->
<mongo:mongo-client
host="localhost"
port="27017">
<mongo:client-options
connections-per-host="8"
threads-allowed-to-block-for-connection-multiplier="4"
connect-timeout="1000"
max-wait-time="1500"
socket-keep-alive="false"
socket-timeout="1500"
/>
</mongo:mongo-client>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo" />
<constructor-arg name="databaseName" value="wc" />
</bean>
</beans>
mongoApp.java 파일에 root-context.xml 을 적용 해보겠습니다.
@Configuration
@ImportResource("classpath:applicationCTX.xml")
public class Application {
@Bean
public CustomerService customerService() {
return new CustomerService();
}
@Bean
public OrderService mongoService() {
return new mongoService();
}
}
한줄 추가로 java 파일에 xml로 작성한 설정파일을 포함시켰습니다.
@ImportResource("classpath:applicationCTX.xml")
@ImportResource 안에 포함시킬 xml 파일의 이름을 적어주면 java로 작성한 파일에 xml 내용이 적용되게 됩니다.
반응형
'Spring' 카테고리의 다른 글
Spring - @Bean을 알아보자 (0) | 2019.03.12 |
---|---|
Spring - 의존객체 자동 주입 (0) | 2019.03.09 |
Spring - XML파일에 JAVA파일 포함시켜 적용하기 (0) | 2019.03.04 |
Spring - XML파일 import 하여 적용하기 (0) | 2019.03.04 |
Spring - 다양한 의존 객체 주입방법 (0) | 2019.03.02 |
Comments