Skip to content

Commit 9df27f3

Browse files
committed
add spring-boot-webflux
1 parent 82d9786 commit 9df27f3

File tree

7 files changed

+122
-0
lines changed

7 files changed

+122
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Spring Boot 使用的各种示例,以最简单、最实用为标准,此开
2929
- [spring-boot-banner](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-hello):Spring Boot 3.0 定制 banner 示例
3030
- [spring-boot-helloworld](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-helloWorld):Spring Boot 3.0 Hello World Test 单元测试示例
3131
- [spring-boot-web](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-web):Spring Boot 3.0 web 示例
32+
- [spring-boot-webflux](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-webflux):Spring Boot 3.0 响应式编程 WebFlux 使用案例
3233
- [spring-boot-redis](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-redis):Spring Boot 3.0 Redis 示例
3334
- [spring-boot-thymeleaf](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-thymeleaf):Spring Boot 3.0 Thymeleaf 语法、布局使用示例
3435
- [spring-boot-jpa](https://github.com/ityouknow/spring-boot-examples/tree/master/spring-boot-jpa):Spring Boot 3.0 Jpa 操作、增删、改查多数据源使用示例

spring-boot-webflux/pom.xml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>com.neo</groupId>
7+
<artifactId>spring-boot-webflux</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<name>spring-boot-webflux</name>
12+
<description>Demo project for Spring Boot</description>
13+
14+
<parent>
15+
<groupId>org.springframework.boot</groupId>
16+
<artifactId>spring-boot-starter-parent</artifactId>
17+
<version>3.0.0</version>
18+
<relativePath/> <!-- lookup parent from repository -->
19+
</parent>
20+
21+
<properties>
22+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23+
<java.version>17</java.version>
24+
</properties>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-webflux</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-test</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.junit.vintage</groupId>
37+
<artifactId>junit-vintage-engine</artifactId>
38+
<scope>test</scope>
39+
<exclusions>
40+
<exclusion>
41+
<groupId>org.hamcrest</groupId>
42+
<artifactId>hamcrest-core</artifactId>
43+
</exclusion>
44+
</exclusions>
45+
</dependency>
46+
</dependencies>
47+
48+
<build>
49+
<plugins>
50+
<plugin>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-maven-plugin</artifactId>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
57+
58+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.neo;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class WebFluxApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(WebFluxApplication.class, args);
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.neo.web;
2+
3+
import org.springframework.web.bind.annotation.GetMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
import reactor.core.publisher.Mono;
6+
7+
@RestController
8+
public class HelloController {
9+
10+
@GetMapping("/hello")
11+
public Mono<String> hello() {
12+
return Mono.just("Welcome to reactive world ~");
13+
}
14+
}

spring-boot-webflux/src/main/resources/application.properties

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.neo;
2+
3+
import com.neo.web.HelloController;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest;
8+
import org.springframework.test.context.junit4.SpringRunner;
9+
import org.springframework.test.web.reactive.server.WebTestClient;
10+
11+
@RunWith(SpringRunner.class)
12+
@WebFluxTest(controllers = HelloController.class)
13+
public class HelloTests {
14+
@Autowired
15+
WebTestClient client;
16+
17+
@Test
18+
public void getHello() {
19+
client.get().uri("/hello").exchange().expectStatus().isOk();
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.neo;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class WebFluxApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)