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
- 이클립스
- 에러페이지
- 생성자
- 메서드
- oracle
- 메소드
- JavaScript
- Android
- OGNL
- 국제화
- AWT
- Java
- struts2
- 기본
- HTML
- 배열
- Spring
- 오버로딩
- mybatis
- Menu
- paint
- 예외처리
- Graphic
- 안드로이드
- 클래스
- Eclips
- 어노테이션
- 전화걸기
- JSP
- layout
Archives
- Today
- Total
note
Spring 프로퍼티 타입을 이용한 의존 관계 자동 설정 본문
applicationContext02.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
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-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 프로퍼티 타입을 이용한 의존 관계 자동 설정 -->
<bean name="writeArticleService2" class="madvirus.spring.chap02.WriteArticleServiceImpl" autowire="byType" />
<bean name="mysqlArticleDao" class="madvirus.spring.chap02.MySQLArticleDao" />
</beans>
Main06
package madvirus.spring.chap02;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main06 {
public static void main(String[] args){
String[] configLocations = new String[] { "applicationContext02.xml" };
ApplicationContext context = new ClassPathXmlApplicationContext(
configLocations);
// 프로퍼티 이름을 이용한 의존 관계 자동 설정
WriteArticleService articleService = (WriteArticleService) context
.getBean("writeArticleService2");
articleService.write(new Article());
}
}
WriteArticleService
package madvirus.spring.chap02;
public interface WriteArticleService {
void write(Article article);
}
Article
package madvirus.spring.chap02;
public class Article {
}
'JSP > Spring' 카테고리의 다른 글
| Spring @Required 어노테이션(Annotation) (0) | 2012.02.29 |
|---|---|
| Spring 국제화 (0) | 2012.02.29 |
| Spring 프로퍼티 이름을 이용한 의존 관계 자동 설정 (0) | 2012.02.29 |
| Spring Di 심화 학습 (0) | 2012.02.29 |
| Spring Di(Dipendency Injection) (0) | 2012.02.28 |