Announcement Announcement Module
No announcement yet.
Resource Availability @Test / MVC Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Resource Availability @Test / MVC

    Hello friends -

    New to Spring and STS so hopefully this isn't too dumb a question. Anyways, created a spring/mvc/hibernate project. Put some @RunWith(SpringJunit4ClassRunner) classes underneath /src/test/java. In src/main/resources/ I put applicationContext.xml + and similar files. Great. Ran some Junits and things were autowiring / applicationContexting, whatever.

    Tried the MVC end. Wound up having to clone my /main/resources files into src/main/webapp/web-inf.

    Whatever I tried, however, I could not seem to enable my classes in /scr/test/java to see resource files in /src/main/webpap/web-inf. Considering that I've got to keep things moving, I just have been keeping two copies of applicationContext.xml even though it's dumb as hell.

    What am I doing wrong?

    Thanks a lot.


  • #2
    Hey Brian!

    I am not sure how you created and setup your project, but is it a dynamic web project in Eclipse/STS? And if so, did you take a look at the deployment assembly in the project properties?

    I can imagine that this sounds a bit complicated when starting with Spring and STS, so I would recommend to start with a fresh Spring MVC project using the Spring Template projects. From there you can easily create a Spring MVC project that works out-of-the-box. In addition to that I would also recommend these resources for how-to-get-started:



    • #3
      Hi Martin -

      Thanks for the response. I think maybe I did a poor job of describing my problem. I created my project using the STS template and then chose 'Spring MVC Project' (not a dynamic web project).

      Anyway, the structure that it created for me struck me as kind of odd, but I kept slugging away and have things running. I can run my Junits successfully. Also, I can run my application (as it exists so far) through a web browser / MVC style. BUT. What I cannot seem to do is have my junit tests see ApplicationContext that resides underneath webapps/web-inf. See the attached screenshot for what my environment looks like and what can see what.


      Attached Files


      • #4
        Hi Brain,

        Is there any chance for zipping the project and publishing it somewhere? A github repo would also work. The screenshot is quite blurry.