I have put the datasource bean definition (before into the configurationContext-dataSource.xml file) into the configurationContext.xml file and it works .
The java code is:
Code:
private ApplicationContext ctx = new ClassPathXmlApplicationContext("configurationContext.xml");
......
protected void setUp() throws Exception {
super.setUp();
carDAO = (CarDao)ctx.getBean("carDao");
}
....
now, the content of configurationContext.xml is:
<beans>
<!-- ========================= DATA SOURCE DEFINITIONS ========================= -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/jbossdb</value>
</property>
<property name="username">
<value>username</value>
</property>
<property name="password">
<value>password</value>
</property>
</bean>
<!-- ========================= GENERAL DEFINITIONS ========================= -->
<!-- Message source for this context, loaded from localized "messages_xx" files -->
<bean id="messageSource" class="org.springframework.context.support.Resourc eBundleMessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<!-- applicationContext merge-point -->
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<property name="dataSource"><ref bean="dataSource"/></property>
<property name="mappingResources">
<list>
<value>/Car.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.provider_class">org.hibernate .cache.EhCacheProvider</prop>
<prop key="hibernate.cache.query_cache_factory">org.hibe rnate.cache.StandardQueryCacheFactory</prop>
</props>
</property>
</bean>
<!-- The Hibernate interceptor -->
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.Hibernat eInterceptor">
<property name="sessionFactory"><ref bean="sessionFactory"/></property>
</bean>
<!-- Car Entity Implementation -->
<bean id="carDaoTarget" class="CarDaoImpl">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
<!-- Car Entity Proxy -->
<bean id="carDao" class="org.springframework.aop.framework.ProxyFact oryBean">
<property name="target"><ref bean="carDaoTarget"/></property>
<property name="proxyInterfaces">
<value>CarDao</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
</list>
</property>
</bean>
So, anybody knows how can I configure different description bean files for using in the same application ?????????. What I did wrong with my first approach??