moudug
moudug

Reputation: 209

Is it possible to set a system path as spring context

I want to load my Spring application context via annotations like this:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:/path/to/spring-context1.xml", "file:/path/to/spring-context2.xml"})

I am trying this because the context file is not in my classpath. I've read several times that this was possible but it does not seem to work. So my question is: "Is this really possible and am I doing something wrong?

I've got another question if this happens to be possible: if I want to use a relative path instead of an absolute one, from where should it be relative? From the pom.xml location?

Upvotes: 3

Views: 174

Answers (1)

moudug
moudug

Reputation: 209

As said in the comments of my first post, the problem came from me ;) So the answers are :

  • yes, you can use the "file:" prefix to set your Spring context
  • yes, you can use relative path, relative to the pom.xml directory

Hope this helps.

Upvotes: 1

Related Questions