我正在学习 Spring 框架,这是在我的项目中使用。我在 Xml文件中找到了 < em > ContextLoaderListener 条目。但是不能弄清楚它到底如何帮助一个开发人员?
在 < em > ContextLoaderListener 的官方文档中,它说它将启动 WebApplicationContext。关于这个问题,JavaDocs 说:
接口为 Web 应用程序提供配置。
但是,我不能理解我是什么实现与 ContextLoaderListener内部初始化的 WebApplicationContext?
根据我的理解 ,ContextLoaderListener读取 Spring 配置文件(根据 Xml中的 contextConfigLocation 给出值) ,解析它并加载该配置文件中定义的 单子豆。类似地,当我们想加载 豆子原型时,我们将使用相同的 Web 应用程序上下文来加载它。因此,我们使用 ContextLoaderListener初始化 webapplication,这样我们就可以提前读取/解析/验证配置文件,并且无论何时我们想要注入依赖项,我们都可以立即执行,没有任何延迟。这个理解正确吗?