我正在使用spring-data-elasticsearch 2.0.0 RELEASE和ElasticSearch 2.2.0
我按照以下方式设置了我的bean:
@Configuration
public class ElasticSearchClient {
@Autowired
private ElasticSerachConfig esConfig;
static final String COLON = ":";
static final String COMMA = ",";
private Settings getSettings(){
return Settings.builder()
.put("client.transport.sniff", esConfig.isClusterSniff())
.put("client.transport.ping_timeout", esConfig.getClientPingTimeout())
.put("client.transport.nodes_sampler_interval", esConfig.getClientNodesSampleInterval())
.build();
}
protected Client buildClient() throws Exception {
TransportClient client = TransportClient.builder().settings(getSettings()).build();
for (String clusterNode : split(esConfig.getClusteNodes(), COMMA)) {
String hostName = substringBeforeLast(clusterNode, COLON);
String port = substringAfterLast(clusterNode, COLON);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
}
client.connectedNodes();
return client;
}
@Bean
public ElasticsearchTemplate getElasticSearchTenplate() throws Exception{
return new ElasticsearchTemplate(buildClient());
}
}
我得到以下异常:
Caused by: java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories.repositoryBaseClass()
at java.lang.reflect.Method.getDefaultValue(Unknown Source) ~[na:1.8.0_60]
at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.registerDefaultValues(RecursiveAnnotationAttributesVisitor.java:69) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.doVisitEnd(RecursiveAnnotationAttributesVisitor.java:57) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.core.type.classreading.AnnotationAttributesReadingVisitor.doVisitEnd(AnnotationAttributesReadingVisitor.java:67) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.core.type.classreading.RecursiveAnnotationAttributesVisitor.visitEnd(RecursiveAnnotationAttributesVisitor.java:48) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.asm.ClassReader.readAnnotationValues(ClassReader.java:1802) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.asm.ClassReader.accept(ClassReader.java:642) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.asm.ClassReader.accept(ClassReader.java:508) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:64) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) ~[spring-core-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:279) ~[spring-context-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]
我在build.gradle中有以下内容:
compile 'org.springframework.data:spring-data-elasticsearch:2.0.0.RELEASE'
compile 'org.springframework.data:spring-data-commons-core:1.4.1.RELEASE'
我有什么遗漏的吗?我几乎遵循spring-data-elasticsearch示例中提供的相同示例。
答案 0 :(得分:0)
Spring数据尚未更新为2.x系列。
更新:好吧。它有!