# project-reactor-learn **Repository Path**: good-person/project-reactor-learn ## Basic Information - **Project Name**: project-reactor-learn - **Description**: 响应式编程 学习 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2020-08-13 - **Last Updated**: 2023-01-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 响应式编程 学习 - **Project Reactor** - 官网:https://projectreactor.io/ - 文档:https://projectreactor.io/docs/core/release/reference/ - 文档:2.4.2. Gradle Installation ```groovy // Since Gradle 5.0, you can use the native Gradle support for BOMs: dependencies { implementation platform('io.projectreactor:reactor-bom:Bismuth-RELEASE') implementation 'io.projectreactor:reactor-core' } ``` - - - 1. **Hello** - `loveqq.hello.HelloWorld` + 自己去玩API 2. **WebFlux** - 文档:https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html - 引入SpringBoot + WebFlux(https://start.spring.io/) ```groovy // 之前的projectreactor依赖可以去除,因为WebFlux自带了 dependencies { implementation platform('org.springframework.boot:spring-boot-dependencies:2.3.2.RELEASE') implementation 'org.springframework.boot:spring-boot-starter-webflux' } ``` - `loveqq.webflux.handler.UserHandler` (WebFlux默认Web容器是:Netty) 3. **WebClient** - `loveqq.webflux.WebClientTest` - `loveqq.webflux.WebTestClientTest` 4. **R2DBC** - 官网:http://r2dbc.io/ - MySQL驱动: ```groovy dependencies { implementation 'dev.miku:r2dbc-mysql:0.8.2.RELEASE' } ``` - `loveqq.r2dbc.HelloWorld` - **Spring Data R2DBC**: ```groovy dependencies { implementation 'dev.miku:r2dbc-mysql:0.8.2.RELEASE' implementation 'org.springframework.boot:spring-boot-starter-data-r2dbc' } ``` - `loveqq.r2dbc.R2dbcTest` - **事务**: 除了`@Transactional`,官网提供第二种方式([链接](https://docs.spring.io/spring-data/r2dbc/docs/1.1.3.RELEASE/reference/html/#r2dbc.datbaseclient.transactions)) ```java ReactiveTransactionManager tm = new R2dbcTransactionManager(connectionFactory); TransactionalOperator operator = TransactionalOperator.create(tm); DatabaseClient client = DatabaseClient.create(connectionFactory); client.execute("SQL语句") ... .as(operator::transactional); // 事务控制 ``` 5. **CRUD** - 使用`Spring Data R2DBC`:案例在`loveqq.crud`包下 - 测试:`loveqq.crud.CrudTest`