e3r45t
e3r45t

Reputation: 51

Spring MVC @ContextConfiguration

I am learning Java and Spring MVC. I found this code:

@ContextConfiguration(locations = { "classpath: com/myname/spring/junit-context.xml" })

I understand that com/myname/spring/junit-context.xml is a relative path. My questions is: what is it relative TO in the context of a web application?

Upvotes: 1

Views: 184

Answers (2)

0gam
0gam

Reputation: 1443

@ContextConfiguration(locations = {
    "file:src/main/webapp/WEB-INF/spring/root-context.xml",
    "file:src/main/webapp/WEB-INF/spring/security-context.xml",
    "file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml" })

webapp -> WEB-INF -> spring -> ContextConfiguration file name


com/myname/spring

com -> myname-> spring-> file name

just folder structure

Upvotes: 0

Augusto
Augusto

Reputation: 29997

It's relative to the classpath (that's why it's prefixed with classpath). You can have several folders and jars in your classpath and Spring will search in all of them for the resource file.

Upvotes: 1

Related Questions