mongodb - 如何使用 spring-boot 指定 spring-data-mongodb 版本?

标签 mongodb maven pom.xml spring-boot

我想使用最新版本的spring-data-mongodb,以便使用全文搜索功能,但我不知道如何使用spring-boot-starter-data-mongodb依赖项指定这一点.

您可以在这里阅读:maven repository没有指定spring-data-mongodb版本。

这是我的 pom 文件:

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

<dependencies>
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>
    <!-- Spring Boot -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!-- Spring Boot Rest -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <!-- Spring Boot Test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <!-- Spring MongoDB integration -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-freemarker</artifactId>
    </dependency>

最佳答案

Spring Boot 在 spring-boot-dependencies 中定义了它所有的依赖和依赖版本。项目。该项目仅包含一个 pom只有依赖项和版本作为属性。

Spring Data 在所谓的发布序列中发布其所有兼容版本,这确保该版本的所有依赖项都可以协同工作。

当您使用 a closer look a the pom您将看到一个名为 spring-data-releasetrain.version 的 maven 属性,对于即将推出的 Spring Boot 1.2,它指向最新的发布火车版本 Evans-RELEASE。 1.1.7 版本指向之前的版本Dijkstra-SR4。我建议从 1.1.6 升级到 1.1.7 以防万一。

您的项目已经将 spring-boot-starter-parent 项目作为其父项目,因此理论上升级 Spring Data 版本应该像覆盖指定属性一样简单。

<properties>
    <spring-data-releasetrain.version>Evans-RELEASE</spring-data-releasetrain.version>
</properties>

如前所述,最好使用发布系列,因为这将确保您获得所有兼容版本。

关于mongodb - 如何使用 spring-boot 指定 spring-data-mongodb 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26141346/

相关文章:

javascript - 从 JavaScript 中的数组中删除双引号

java - 将 Maven 依赖项部署到 S3 : No connector available

java - JAXB 和 complexType 与其元素之一共享名称会生成不正确的代码

java - log4j2 错误 StatusLogger 未找到 log4j2 配置文件且 ResourceBundle 错误

configuration - 排除 Jacoco 覆盖率报告中的文件

java - 本地存在 Maven 依赖项时出现 NoClassDefFoundError

MongoDB:从数组字段中的所有子文档中删除一个字段

java - 如何通过Java驱动在MongoDB中创建复合索引?

node.js - Mongoose 更新查询继续以 upsert true 插入数据,而无需更新和仅添加 1 个字段

java - Maven:发现从元素 "reportSets"开始的无效内容