1

From this link it is clear that there are 2 types of context in Spring - one is application context ApplicationContext and another is WebApplicationContext, and I could have multiple WebApplicationContext if I declare multiple servlets using org.springframework.web.servlet.DispatcherServlet. Correct me if I am wrong till.

Now, WebApplicationContext also an interface and extends ApplicationContext, then at runtime which would be actual class implementing these interfaces? I read about didn't became clear to me, my ballpark guess is that XmlWebApplicationContext could implement ApplicationContext, but then what your implementation of WebApplicationContext?

Now, suppose I have a controller bean @Controller and a respository bean @Repository bean, now considering the fact that I have 2 different contexts - one is application context "ApplicationContext" and another is "WebApplicationContext", suppose I did @Autowire ApplicationContext appContext in both my controller and repository then would the actual object injection depend upon whether it is controller class or repository class? (assume that I have different beans defined in configuration files pointed by "ApplicationContext" and "WebApplicationContext").

Community
  • 1
  • 1
pjj
  • 2,015
  • 1
  • 17
  • 42

0 Answers0