首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >spring-data-elasticsearch中的XSD验证错误

spring-data-elasticsearch中的XSD验证错误
EN

Stack Overflow用户
提问于 2014-11-05 05:44:14
回答 1查看 243关注 0票数 1

有没有人对这个无效的spring-data-elasticsearch.xsd文件有解决方案?

http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd

我尝试加载这个xml文件:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">

    <elasticsearch:transport-client id="ElasticSearchClient" cluster-nodes="localhost:9300" />

    <bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
        <constructor-arg name="client" ref="ElasticSearchClient" />
    </bean>
</beans>

但是我得到了这些错误:

代码语言:javascript
复制
Caused by: org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd; lineNumber: 40; columnNumber: 116; s4s-att-invalid-value: Invalid attribute value for 'source' in element 'documentation': cvc-datatype-valid.1.2.1.

我发现了一些关于它的问题,但没有人有解决方案。而且不可能在GitHub项目中产生错误问题。

谢谢你,马塞尔

EN

回答 1

Stack Overflow用户

发布于 2014-11-05 17:00:30

我认为使用xsd不可能没有问题。因此,我为此创建了一个配置bean。

代码语言:javascript
复制
package org.example;

import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;

@Configuration
class ElasticsearchConfiguration
{   
    @Bean(name="elasticsearchTemplate")
    public ElasticsearchOperations elasticsearchTemplate()
    {
        Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("127.0.0.1", 9300));       
        return new ElasticsearchTemplate(client);
    }
}

这对我很有效..。

马塞尔

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26745607

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档