gpt4 book ai didi

java - 有多个 Spring "application context"的目的是什么

转载 作者:行者123 更新时间:2023-12-01 18:00:14 26 4
gpt4 key购买 nike

Per the Spring Documentation ,应用程序上下文是:

Central interface to provide configuration for an application. This is read-only while the application is running, but maybe reloaded if the implementation supports this.

在某些应用程序中,存在多个应用程序上下文。拥有多个应用程序上下文的目的和好处是什么?我想了解其背后的逻辑。为什么要这么做?

P.S:在 spring doc use 中是这样写的。我想知道拥有多个应用程序上下文的优点及其背后的基本原理。

最佳答案

根上下文是每个调度程序servlet上下文/子上下文的父上下文。 根上下文中定义的 Bean 对每个调度程序 servlet 上下文/子上下文可见,但反之亦然。

通常,根上下文用于定义所有横切 bean,例如安全性、事务和其他配置 bean,而调度程序上下文 code> 或 child context 包含与 MVC 特别相关的那些 bean。

当我们需要多组 MVC 配置时,我们会创建多个调度程序 servlet。例如我们可能有一个 REST API 以及传统的 MVC 应用程序或网站的不安全部分和安全部分。

enter image description here

关于java - 有多个 Spring "application context"的目的是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60649510/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com