Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML files needed for developing using Spring MVC and Hibernate?

 
Gaurav Sandil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the XML files needed for developing an application using Spring MVC and Hibernate
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no answer to your question. What do you exactly mean?

I might have 2 xml files, or I might have 20 xml files in my Spring MVC/Hibernate application. or any number in between.

Mark
 
Gaurav Sandil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean to say that I have seen some code where they have used applicationContext.xml and DispatcherServlet.xml(usually Servlet name follwed by-servlet.xml) and seen some examples where they used only one.
What are the uses of these two xml files.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurav Sandil wrote:I mean to say that I have seen some code where they have used applicationContext.xml and DispatcherServlet.xml(usually Servlet name follwed by-servlet.xml) and seen some examples where they used only one.
What are the uses of these two xml files.


Cool, that makes more sense.

So with you have xxx-servlet-xml, that typically has just the Web Layer beans.

The applicationContext.xml has the middle tier beans like your services and repositories, as well as importing the xml files that have your infrastructure beans like dataSource and transactionManager.

Each of these files is actually loaded by different classes making two different ApplicationContext instances. One for the middle tier beans and one for the web layer beans which separates them in a good way. The Web Layer will have full access to beans in the middle tier, but not the other way around. But you do not want your middle tier to see any beans from your web layer. You should be able to call down the stack, but not up.

When you have seen it where they only have one file and one loading of the application context, those people are just not separating out the layers. You can do this and everything works, but I personally don't recommend it.

Mark
 
Gaurav Sandil
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Mark..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic