gpt4 book ai didi

Spring XML 命名空间 : How do I find what are the implementing classes behind them?

转载 作者:IT老高 更新时间:2023-10-28 13:45:57 24 4
gpt4 key购买 nike

在我的 Spring 3.1 应用程序中,有时我需要更改上下文文件中某些 Spring 命名空间的默认行为。为此,我创建了实现某些接口(interface)或扩展 Spring 使用的默认类的自定义类。

但我发现很难确切知道 Spring 在其命名空间后面使用的那些类是什么!找到它们需要哪些步骤?

例如,安全命名空间:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">

类似的东西:

<sec:http>
...
<sec:logout />
</sec:http>

如何找到“ ”命名空间使用了哪些类?我没有通过查看 http://www.springframework.org/schema/security/spring-security-3.1.xsd 找到信息!

我应该去哪里看?

最佳答案

每个 Spring 命名空间都有一个关联的 NamespaceHandler执行。命名空间模式映射到 Spring JAR 中各种 spring.schemas 文件中的模式文件(另见 Spring DI applicationContext.xml how exactly is xsi:schemaLocation used?)。

XML 模式命名空间也映射到 spring.handlers 文件中的处理程序类(因为每个 Spring JAR 可能会引入不同的命名空间)。为方便起见,这里列出了最常见的命名空间:

Spring 芯

Spring 安全

Spring 集成

如果您浏览每个类的源代码,您会很快发现负责解析实际 XML 定义的各种 BeanDefinitionParser 实现。

关于Spring XML 命名空间 : How do I find what are the implementing classes behind them?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11174286/

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