#yyds干货盘点#Reactive访问Spring Data MongoDB

Posted zhz小白

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了#yyds干货盘点#Reactive访问Spring Data MongoDB相关的知识,希望对你有一定的参考价值。

MongoDB 官⽅提供了⽀持 Reactive 的驱动

  • mongodb-driver-reactivestreams
  • Spring Data MongoDB 中主要的⽀持
  • ReactiveMongoClientFactoryBean
  • ReactiveMongoDatabaseFactory
  • ReactiveMongoTemplate

1、Pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zhz</groupId>
<artifactId>reactive-spring-boot-mongodb-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>reactive-spring-boot-mongodb-demo</name>
<description>Spring Boot使用reactive集成mongodb</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>

<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-money</artifactId>
<version>1.0.1</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

2、yml

spring:
data:
mongodb:
uri: mongodb://springbucks:springbucks@localhost:27017/springbucks

3、代码

package com.zhz.reactive.model;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import 以上是关于#yyds干货盘点#Reactive访问Spring Data MongoDB的主要内容,如果未能解决你的问题,请参考以下文章

#yyds干货盘点#Reactive访问Spring Data R2DBC

#yyds干货盘点#Vue3的reactive

Springboot自动装配详解#yyds干货盘点#

PyTorch教程 参数访问#yyds干货盘点#

#yyds干货盘点# springboot整合JPA访问Mysql

Windows 11 开启外网访问mysql之 防火墙设置 #yyds干货盘点#