i have situation this. have junit test class in have mentioned @contextconfiguration class load @contextconfiguration main/resource , other files included in it(datasource.xml , hibernate.xml) test/resources.
please see below code
test class
@runwith(springjunit4classrunner.class) @contextconfiguration(locations={"classpath*:/meta-inf/spring/springbeanconfiguration.xml"}) springbeanconfiguration.xml
<!-- database configuration --> <import resource="classpath:meta-inf/database/datasource.xml"/> <import resource="classpath:meta-inf/database/hibernate.xml"/> there file named springbeanconfiguration.xml resides both in test/resources , main/resource.
if have maven project, can configure maven-surefire-plugin (used in test phase) declare src/main/webapp additional classpath element during test execution.
or specify of them this:
@contextconfiguration(locations = {"classpath*:/meta-inf/database/datasource.xml", "classpath*:/meta-inf/database/hibernate.xml"})
Comments
Post a Comment