messageSource 적용 여부
- 작성자 :
- 김*희
- 작성일 :
- 2010-08-16 16:20:23
- 조회수 :
- 3,299
- 구분 :
- 실행환경
- 진행상태 :
- 완료
Q
안녕하세요?
현재 진행중인 프로젝에서는 각 DAO 파일의 공통모듈을 처리하기 위해, CommonDAO를 만들어, 각 DAO가 상속받도록 하고 있습니다.(
즉, 이렇게요.
public class XXXXDAO extends CommonDAO
그리고 CommonDAO는
public class CommonDAO extends EgovAbstractDAO 의 형태입니다.
이 CommonDAO에서 messageSource를 사용하기 위해
@Repository("CommonDAO") 라고 정의해 주었는데, 이렇게 정의했는데도, messageSource가 null 이 찍히네요.
============================
@Repository("CommonDAO")
public class CommonDAO extends EgovAbstractDAO {
@Resource(name = "messageSource")
protected MessageSource messageSource;
@Autowired
public CommonDAO(SqlMapClient sqlMapClient) {
//super();
setSqlMapClient(sqlMapClient);
logger.debug("=== messageSource====== " + messageSource); ==> null
}
public CommonDAO() {
logger.debug("=== CommonDAO 생성 ====== ");
logger.debug("=== messageSource====== " + messageSource); ==> null
CommonDAO에서 messageSource를 꼭 사용해야 하는데, 방법을 좀 알려주세요.
현재 진행중인 프로젝에서는 각 DAO 파일의 공통모듈을 처리하기 위해, CommonDAO를 만들어, 각 DAO가 상속받도록 하고 있습니다.(
즉, 이렇게요.
public class XXXXDAO extends CommonDAO
그리고 CommonDAO는
public class CommonDAO extends EgovAbstractDAO 의 형태입니다.
이 CommonDAO에서 messageSource를 사용하기 위해
@Repository("CommonDAO") 라고 정의해 주었는데, 이렇게 정의했는데도, messageSource가 null 이 찍히네요.
============================
@Repository("CommonDAO")
public class CommonDAO extends EgovAbstractDAO {
@Resource(name = "messageSource")
protected MessageSource messageSource;
@Autowired
public CommonDAO(SqlMapClient sqlMapClient) {
//super();
setSqlMapClient(sqlMapClient);
logger.debug("=== messageSource====== " + messageSource); ==> null
}
public CommonDAO() {
logger.debug("=== CommonDAO 생성 ====== ");
logger.debug("=== messageSource====== " + messageSource); ==> null
CommonDAO에서 messageSource를 꼭 사용해야 하는데, 방법을 좀 알려주세요.
A
안녕하세요... 김선희님..
우선 CommonDAO를 다른 DAO들이 상속하여 사용하더라도...
XXXXDAO를 일반적인 new 생성 방식으로 호출하셨다면..
DI가 적용되지 않습니다..
XXXXDAO 자체가 @Repository로 정의되어서.. 다른 @Service에서 @Resource 또는 @Autowired되어 있지 않으면 안될 것 같습니다.
공통 처리 부분을 다른 방식으로 구현하셔야 할 것 같습니다.
그럼.. 즐거운 하루되십시오.
감사합니다.
우선 CommonDAO를 다른 DAO들이 상속하여 사용하더라도...
XXXXDAO를 일반적인 new 생성 방식으로 호출하셨다면..
DI가 적용되지 않습니다..
XXXXDAO 자체가 @Repository로 정의되어서.. 다른 @Service에서 @Resource 또는 @Autowired되어 있지 않으면 안될 것 같습니다.
공통 처리 부분을 다른 방식으로 구현하셔야 할 것 같습니다.
그럼.. 즐거운 하루되십시오.
감사합니다.