Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5985473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:32:06+00:00 2026-05-22T22:32:06+00:00

There is a tutorial video that introduces Spring MVC 3.0. In the demo-project they

  • 0

There is a tutorial video that introduces Spring MVC 3.0. In the demo-project they use the following directory structure:

<proj>
   src
      main
         webapp
            WEB-INF
               spring
                  appServlet
                     controllers.xml
                     servlet-context.xml
                  root-context.xml

Let’s say I have a project with Maven-support and I want to write JUnit tests using Spring’s configuration. Currently we use JUnit 4.8.2. This would obviously require to load the three files listed above.

In the test I could use annotations like

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath*:/WEB-INF/spring/**/*.xml")

However, that doesn’t find the XML-files. I took a look at the classpath and noticed, that only the <proj>/target/classes and <proj>/target/test-classes are included by default.

One obvious solution would be to add the proper path to the classpath, but I don’t know if that is what the guys at Spring had in mind.

Therefore, my question: What do I need to do to load the configuration files while letting it look as if I’m the total pro-coder using Spring?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:32:06+00:00Added an answer on May 22, 2026 at 10:32 pm

    You should put the “normal” spring configuration in the resources folder but not in the webapp folder: src\main\ressources\WEB-INF\spring\root/spring-context.xml. Then you can access it without problems from the test.

    Put only the web related spring configuration (servlet-context.xml) in the webapp folder.


    The structure that you described is the one generated by the STS-Spring-Template:MVC-Template, however Spring-ROO and Spring-Fuse generate the structure that I have described.
    For example Spring ROO:

    <project>/src/main/resources/META-INF/spring/applicationContext.xml
    <project>/src/main/webapp/WEB-INF/spring/webmvc-config.xml
    <project>/src/main/webapp/WEB-INF/web.xml
    

    web.xml:

    ...
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
    </context-param>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If there is an easy to follow instruction or tutorial that I can use
Is there a .NET library/tutorial available that will let me show me how to
Is there a good tutorial on using regular expressions, especially with grep ? I
Is there a good tutorial or does anyone have experience with setting this up
Is there any good article, tutorial or similar references on interpreting the Execution Plan
What references offer a good summary/tutorial for using RDF/OWL? There seem to be enough
I want to make a tutorial and I am wondering if there is a
I currently have a network camera that streams video as a .swf (and also
I've been watching this tutorial http://windowsclient.net/learn/video.aspx?v=296114 . At the very begining empty Windows forms
(Relating to an earlier question of mine: Playing a Video (MSDN Tutorial) ) I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.