Jūs esate

How to load Spring Application context for jUnit from WEB-INF?

I'm using jUnit for writing unit tests for my applications.

It's easy to load applicationContext.xml when it's in classpath:

[geshifilter-java] @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath*:applicationContext.xml"}) public abstract class DefaultApplicationContext { // Code [/geshifilter-java]

But how to load application context not from classpath, but from custom directory, for example WEB-INF?

Solution is to use Maven's path:

[geshifilter-java] @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"file:src/main/webapp/WEB-INF/applicationContext.xml"}) public abstract class DefaultApplicationContext { // Code [/geshifilter-java]
Kategorija: 

Komentuoti