如何在 Spring Boot 2.6.4 中导入 spring-boot-starter-data-solr

发布于 2025-01-13 02:36:56 字数 1999 浏览 1 评论 0原文

我正在学习在springboot中使用solr,我尝试了一本书上的程序,书中的spring-boot-starter-parent版本是2.1.2.RELEASE:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

而我的spring-boot-starter-parent版本是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>

我在 pom.xml 中添加了 solr 依赖项,如下所示:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-solr</artifactId>
        </dependency>

但是 pom.xml 显示错误:版本不能为空,所以我转到 https://mvnrepository.com/ 发现最新的 spring-boot-starter-data-solr 版本是 2.4.13,所以我像这样添加 solr 依赖

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-solr</artifactId>
            <version>2.4.13</version>
        </dependency>

:现在xml已经没有错误了,但是import solr的java程序仍然无法运行,比如:

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;

找不到任何关于solr的类。我还尝试在 https://mvnrepository.com/ 中下载 spring-boot-starter-data-solr jar ,我在本地导入它,但我只在下载的 spring-boot-starter-data-solr jar 中找到一个 META-INF 文档,它没有任何类,

那么我应该如何在 springboot 中使用 solr ?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人练习一个人 2025-01-20 02:36:56

Spring Data for Apache Solr 项目已停止。因此,它在 2021.0.0 版本中从 Spring Data 版本系列中删除 以及来自 Spring Boot 2.5.0 版本

如果您直接使用 Solr,而不是通过 Spring Data,则可以继续这样做。您必须直接声明 Solr 依赖项,而不是依赖 Data Solr 启动器,并且必须在应用程序中配置 Solr,而不是依赖 Spring Boot 的自动配置来执行此操作。

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.

绅刃 2025-01-20 02:36:56

solr-solrj 可能是未更新的 spring-data-solr

solr-solrj is probably the updated alternative to the not updated spring-data-solr.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文