티스토리 뷰

* 개요

Hibernate 사용시 복수의 데이터베이스 연결하고 싶을때. 



* 절차 - 그냥 하던대로 하면 됨.


1.  root-context 에 별도의 DataSource, SessionFactory, (+TransactionManager) Bean 정의


2. 별도의 hibernate.cfg.xml 정의

3. DAO 에 SessionFactory @Autowired 로 연결하고 있다면

@Qualifier("세션팩토리이름") 추가로 선언해줘야 함.


- 안해주면 세션팩토리 하나일때와 달리, 찾을 수 없으므로 다음 예외 발생

org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.hibernate.SessionFactory' available: expected single matching bean but found 2: sfNlp,sfIrs


https://stackoverflow.com/questions/32765984/multiple-sessionfactory-configuration-fails-with-org-springframework-beans-facto?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/04   »
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
글 보관함