当前位置: 首页 > 知识库问答 >
问题:

如何使用Spring data mongoDB2.1.0.RELEASE与Spring boot2.0.5和Jhipster 5.3.3?

刁远
2023-03-14

我正在使用spring-boot 2.0.5.RELEASE与Jhipster 5.3.3,我的pom如下:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.github.jhipster</groupId>
            <artifactId>jhipster-dependencies</artifactId>
            <version>${jhipster-dependencies.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- jhipster-needle-maven-add-dependency-management -->
    </dependencies>
</dependencyManagement>
...
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
...

现在,当我得知spring data发布了对MongoDB4事务管理的支持时,我想尝试一下,因为这听起来很酷!

基于Spring参考留档:https://docs.spring.io/spring-data/mongodb/docs/2.1.0.RELEASE/reference/html/#dependencies

使用spring data mongodb 2.1.0.RELEASE和spring boot就像添加releasetrain的BOM一样简单。我做了,我的pom变成了:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.github.jhipster</groupId>
            <artifactId>jhipster-dependencies</artifactId>
            <version>${jhipster-dependencies.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- jhipster-needle-maven-add-dependency-management -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-releasetrain</artifactId>
            <version>Lovelace-RELEASE</version>
            <scope>import</scope>
            <type>pom</type>
        </dependency>
    </dependencies>

</dependencyManagement> 

但这并没有带来任何spring data MongoDB 2 . 1 . 0 jar,只有releasetrain lovelace的pom。Maven只下载releasetrain的pom,保持下载spring boot 2.0.5附带的spring数据mongodb 2.0.10。

共有2个答案

巢权
2023-03-14

我找到了这样做的方法,因为我使用Jhipster作为我的项目pom的父项目,我必须在Jhipster之前声明lovelace依赖管理,所以我的pom变成:

<dependencyManagement>
  <dependencies>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-releasetrain</artifactId>
        <version>Lovelace-RELEASE</version>
        <scope>import</scope>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>io.github.jhipster</groupId>
        <artifactId>jhipster-dependencies</artifactId>
        <version>${jhipster-dependencies.version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencies>

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

然后Maven将下载lovelace的depenedncy management中指定的spring data mongodb版本。

我不得不阅读Spring引导参考指南来理解这一点。

燕鸿波
2023-03-14

也在pom.xml中添加spring-data-mongodb

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-mongodb</artifactId>
    </dependency>
 类似资料:
  • 我需要在具有自签名证书的Spring Boot 2.0.5应用程序上启用HTTPS,然而,到目前为止,我在配置中发现的所有内容都与设置一个名为的属性有关,但在这个Spring Boot版本上,该属性似乎不推荐使用...在Spring Boot应用程序上启用HTTPS还有其他方法吗?

  • xpack.security.transport.ssl.enabled:true xpack.security.transport.ssl.verification_mode:证书 xpack.security.transport.ssl.keystore.path:ellastic-certificates.p12 xpack.security.http.ssl.client_authenti

  • 在过去的几天里,我尝试为Git版本配置Maven发布插件。我已经为它设置了一个测试项目,我尝试了很多配置,以至于我不知道如何将它们全部显示给您... 在任何情况下,Maven Release插件都只使用当前签出的分支。如果我在主分支上启动发布插件,它会在上面创建标签,但是如果我在开发分支上,它会在那里创建所有东西。 我的实际pom是这样的: 我搜索了很多网站,找不到使用Git的Releasplug

  • 问题内容: 我有如下表 如何通过下面的AND组合成一个IN语句来使用Restriction.in查询? 问题答案: 我认为这是您要使用的条件组合(顺便说一句,帮助Hibernate实体bean定义而不是表结构更容易):

  • 问题内容: 我有下面的表格 如何通过下面的AND组合成一个IN语句来使用Restriction.in查询? 问题答案: 我认为这是您要使用的条件组合(顺便说一句,帮助Hibernate实体bean定义而不是表结构更容易):

  • 场景:我有一个使用springboot+springmvc的web应用程序,springParent的版本是2.2.6版本,我尝试使用jasypt-spring-boot-starter加密数据源用户名和密码,版本是3.0.2。maven clean包(war)是成功的,但在Tomcat中运行失败。下面是错误消息和配置截图: 错误消息: pom.xml