java - In Spring Boot Web, Is it safe to share AnnotationConfigWebApplicationContext between multiple Web Contexts - Stack Overf

admin2025-04-26  7

I am using Spring Boot 3.3.5 and I create custom contexts by overriding tomcatFactory.

As all our custom contexts share similar behavior (same REST Controller, same behavior) and is only differentiated by their Context Path to help us differentiate which custom Data Source to access, is it OK for all the web contexts to use the same AnnotationConfigWebApplicationContext and DispatcherServlet?

My only concern is the AnnotationConfigWebApplicationContext.setServletContext which is required by some Spring Boot web autoconfiguration, and I only call this once by setting the ServletContext of the first custom Context created.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745668534a313169.html

最新回复(0)