diff --git a/persistence-modules/spring-data-solr/pom.xml b/persistence-modules/spring-data-solr/pom.xml
index d7523e6de2..c68c405137 100644
--- a/persistence-modules/spring-data-solr/pom.xml
+++ b/persistence-modules/spring-data-solr/pom.xml
@@ -45,7 +45,7 @@
- 2.0.5.RELEASE
+ 4.3.14
\ No newline at end of file
diff --git a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java
index 1fe1e5468b..54a9816114 100644
--- a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java
+++ b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/config/SolrConfig.java
@@ -9,13 +9,13 @@ import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
@Configuration
-@EnableSolrRepositories(basePackages = "com.baeldung.spring.data.solr.repository", namedQueriesLocation = "classpath:solr-named-queries.properties", multicoreSupport = true)
+@EnableSolrRepositories(basePackages = "com.baeldung.spring.data.solr.repository", namedQueriesLocation = "classpath:solr-named-queries.properties")
@ComponentScan
public class SolrConfig {
@Bean
public SolrClient solrClient() {
- return new HttpSolrClient("http://localhost:8983/solr");
+ return new HttpSolrClient.Builder("http://localhost:8983/solr").build();
}
@Bean
diff --git a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java
index 5649cd7888..677073a58b 100644
--- a/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java
+++ b/persistence-modules/spring-data-solr/src/main/java/com/baeldung/spring/data/solr/repository/ProductRepository.java
@@ -1,6 +1,7 @@
package com.baeldung.spring.data.solr.repository;
import java.util.List;
+import java.util.Optional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -11,6 +12,8 @@ import com.baeldung.spring.data.solr.model.Product;
public interface ProductRepository extends SolrCrudRepository {
+ public Optional findById(String id);
+
public List findByName(String name);
@Query("id:*?0* OR name:*?0*")
diff --git a/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java b/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java
index f86adcdc8a..2208ffadc0 100644
--- a/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java
+++ b/persistence-modules/spring-data-solr/src/test/java/com/baeldung/spring/data/solr/repo/ProductRepositoryLiveTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.spring.data.solr.repo;
+ package com.baeldung.spring.data.solr.repo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -36,7 +36,7 @@ public class ProductRepositoryLiveTest {
product.setId("P000089998");
product.setName("Desk");
productRepository.save(product);
- final Product retrievedProduct = productRepository.findOne(product.getId());
+ final Product retrievedProduct = productRepository.findById(product.getId()).get();
assertEquals(product.getId(), retrievedProduct.getId());
}
@@ -51,7 +51,7 @@ public class ProductRepositoryLiveTest {
product.setName("Shirt");
productRepository.save(product);
- final Product retrievedProduct = productRepository.findOne(product.getId());
+ final Product retrievedProduct = productRepository.findById(product.getId()).get();
assertEquals(product.getName(), retrievedProduct.getName());
}
@@ -64,7 +64,7 @@ public class ProductRepositoryLiveTest {
productRepository.delete(product);
- Product retrievedProduct = productRepository.findOne(product.getId());
+ Product retrievedProduct = productRepository.findById(product.getId()).get();
assertNull(retrievedProduct);
}
@@ -97,7 +97,7 @@ public class ProductRepositoryLiveTest {
wirelessCharger.setName("Phone Charging Cable");
productRepository.save(wirelessCharger);
- Page result = productRepository.findByCustomQuery("Phone", new PageRequest(0, 10));
+ Page result = productRepository.findByCustomQuery("Phone", PageRequest.of(0, 10));
assertEquals(3, result.getNumberOfElements());
}
@@ -118,7 +118,7 @@ public class ProductRepositoryLiveTest {
wirelessCharger.setName("Phone Charging Cable");
productRepository.save(wirelessCharger);
- Page result = productRepository.findByNamedQuery("one", new PageRequest(0, 10));
+ Page result = productRepository.findByNamedQuery("one", PageRequest.of(0, 10));
assertEquals(3, result.getNumberOfElements());
}