有没有人对这个无效的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项目中产生错误问题。
谢谢你,马塞尔
发布于 2014-11-05 17:00:30
我认为使用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);
}
}这对我很有效..。
马塞尔
https://stackoverflow.com/questions/26745607
复制相似问题