It not necessary but recommended. Using separated configuration files you can isolate the web
from the other world for security reasons(eg more secure). You can make a spring-boot program even without a single configuration file by annotations.
The application
context is a bigger context, it means the beans defined in this context can be referred by servlet
context but not vice versa.
Separation of concerns is just a best practice. No fire will suddenly appear if you ignore it, but you will have harder to maintain code. And if you carefully design your application with a web layer a service layer and a persistence layer, storing the beans in the proper application context will just make things simpler.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.