2014-11-04 69 views
1

有没有人为无效的spring-data-elasticsearch.xsd文件提供解决方案?spring-data-elasticsearch中的XSD验证错误

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

我尝试加载这个XML文件:

<?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> 

但即时得到这些错误:

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项目中无法创建错误问题。

感谢 马塞尔

回答

0

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

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); 
    } 
} 

为我的作品....

马塞尔