#151 - Updated Solr examples to use Solr 5.

This commit is contained in:
Oliver Gierke
2016-02-12 12:15:20 +01:00
parent 500359015c
commit 6ccc59004b
2 changed files with 9 additions and 6 deletions

View File

@@ -35,6 +35,7 @@
<apt.version>1.1.3</apt.version>
<java.version>1.8</java.version>
<querydsl.version>4.0.8</querydsl.version>
<solr.version>5.4.1</solr.version>
<spring-data-releasetrain.version>Hopper-BUILD-SNAPSHOT</spring-data-releasetrain.version>
</properties>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,10 +17,12 @@ package example.springdata.solr;
import example.springdata.solr.product.Product;
import java.util.stream.IntStream;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
@@ -30,6 +32,7 @@ import org.springframework.data.solr.core.SolrTemplate;
/**
* @author Christoph Strobl
* @author Oliver Gierke
*/
@Configuration
@EnableAutoConfiguration
@@ -39,7 +42,7 @@ public class SolrTestConfiguration {
@Bean
public SolrTemplate solrTemplate() {
return new SolrTemplate(new HttpSolrServer("http://localhost:8983/solr"), "collection1");
return new SolrTemplate(new HttpSolrClient("http://localhost:8983/solr"), "collection1");
}
/**
@@ -60,8 +63,7 @@ public class SolrTestConfiguration {
protected void doInitTestData(CrudRepository<Product, String> repository) {
for (int i = 0; i < 100; i++) {
repository.save(Product.builder().id("p-" + i).name("foobar").build());
}
IntStream.range(0, 100)
.forEach(index -> repository.save(Product.builder().id("p-" + index).name("foobar").build()));
}
}