以spring-data-elasticsearch-2.0.0RELEASE.jar为例
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
**xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"**
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
name="elasticsearch" />
class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
首先找到xml命名空间
此处标明spring解析谁的命名规则空间
其次找到spring与elasticsearch的集成jar,spring-data-elasticsearch.jar
找到META-INF,
再找到其下spring.handlers会发现有如下一行
2:
注意1和2的关系,此行表示spring对elasticsearch的集成xml命名空间由此类来实现解析、装配
之后就是去spring-data-elasticsearch.jar中找到
org.springframework.data.elasticsearch.config.ElasticsearchNamespaceHandler这个类
详细查看如何对类似
此分析由马老板指导,有理解不足之处,望指正