What is the intentional use of `servlet-context.xml`,` root-context.xml` and `web.xml`?

I am new to Java Spring web MVC development. I am a little confused by the 3 configuration files below. They are automatically created using the STM webmvc project template.

  • What is their use?
  • Why do we need 3 configuration files, not one?
  • Is there any special reason for their different places?

enter image description here

+4
source share
1 answer

root-context.xmlis the Spring Root contextual configuration . It's not obligatory. It is designed to configure non-web beans. This is required for Spring Security or OpenEntityManagerInView Filter. Better put it in meta-inf/spring.

servlet-context.xml - Spring . Spring beans -. root-context.xml, - beans root-context.xml beans servlet-context.xml.

web.xml , Tomcat. . - . web.xml, , -.

xml JavaConfig.

+10

Source: https://habr.com/ru/post/1570803/


All Articles