I'm studying using solr in springboot, I try the program in a book, the spring-boot-starter-parent version is 2.1.2.RELEASE in the book:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
while my spring-boot-starter-parent version is 2.6.4:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
and I add the solr dependency in pom.xml like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-solr</artifactId>
</dependency>
but the pom.xml shows error: The version cannot be empty, so I go to https://mvnrepository.com/ and find the latest spring-boot-starter-data-solr version is 2.4.13, so I add the solr dependcy like this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-solr</artifactId>
<version>2.4.13</version>
</dependency>
the pom.xml has no error now, but the java program which import solr still not work, such as:
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
it cannot find any class about solr. I also try to download the spring-boot-starter-data-solr jar in https://mvnrepository.com/, and I import it locally, but I only find a META-INF document in the spring-boot-starter-data-solr jar downloaded, it doesn't have any classes
so how should I use solr in springboot?
CodePudding user response:
The Spring Data for Apache Solr project has been discontinued. As a result, it was removed from the Spring Data release train in its 2021.0.0 release and from Spring Boot in its 2.5.0 release.
If you are using Solr directly, rather than via Spring Data, you can continue to do so. You will have to declare your Solr dependencies directly rather than relying on the Data Solr starter and you will have to configure Solr in your application rather than relying on Spring Boot's auto-configuration to do so.