I have two shared project : "configdb" and "scheduledb".And i have two sessionFactorys : sessionFactoryConfigDb and sessionFactoryScheduleDb.
My code: in configDb
and scheduleDbCode:@Resource(type=SessionFactory.class,name="sessionFactoryConfigDb") // @Required public void setSessionFactoryConfigDb(SessionFactory sessionFactoryConfigDb) { this.sessionFactory = sessionFactoryConfigDb; this.hibernateTemplate = new HibernateTemplate(sessionFactoryConfigDb); }
But i have this error:Code:@Resource(type=SessionFactory.class,name="sessionFactoryScheduleDb") // @Required public void setSessionFactoryScheduleDb(SessionFactory sessionFactoryScheduleDb) { this.sessionFactory = sessionFactoryScheduleDb; this.hibernateTemplate = new HibernateTemplate(sessionFactoryScheduleDb); }
Error creating bean with name 'pollerConfigDao': Injection of autowired depe
ndencies failed; nested exception is org.springframework.beans.factory.BeanCreat
ionException: Could not autowire method: public void org.appfuse.dao.hibernate.G
enericDaoHibernate.setSessionFactory(org.hibernate .SessionFactory); nested excep
tion is org.springframework.beans.factory.NoSuchBeanDefini tionException: No uniq
ue bean of type [org.hibernate.SessionFactory] is defined: expected single match
ing bean but found 2: [sessionFactoryScheduleDb, sessionFactoryConfigDb]
first,I tried "@Autowired" with "@Qualifier" and many ways but i have the same error. I run project as deskptop application.I have error when i run .jar file. When i run on eclipse no error occurred.
Please help me! and sorry for my English.


Reply With Quote