Skip to content

Commit

Permalink
Spring Boot 2.x WebFlux 入门
Browse files Browse the repository at this point in the history
  • Loading branch information
weiwosuoai committed Apr 15, 2019
1 parent de781c9 commit 516e404
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 0 deletions.
48 changes: 48 additions & 0 deletions spring-boot-webflux-hello/pom.xml
@@ -0,0 +1,48 @@
<?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 http://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.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>site.exception</groupId>
<artifactId>spring-boot-webflux-hello</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-webflux-hello</name>
<description>Demo project for Spring Boot</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-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>
@@ -0,0 +1,13 @@
package site.exception.springbootwebfluxhello;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootWebfluxHelloApplication {

public static void main(String[] args) {
SpringApplication.run(SpringBootWebfluxHelloApplication.class, args);
}

}
@@ -0,0 +1,32 @@
package site.exception.springbootwebfluxhello.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import site.exception.springbootwebfluxhello.entity.User;

/**
* @author 犬小哈 (微信号: 小哈学Java)
* @site 个人网站: www.exception.site
* @date 2019/4/15
* @time 下午9:12
* @discription
**/
@RestController
public class HelloWebFluxController {

@GetMapping("/hello")
public String hello() {
return "Hello, WebFlux !";
}

@GetMapping("/user")
public Mono<User> getUser() {
User user = new User();
user.setName("犬小哈");
user.setDesc("欢迎关注我的公众号: 小哈学Java");
return Mono.just(user);
}


}
@@ -0,0 +1,36 @@
package site.exception.springbootwebfluxhello.entity;

/**
* @author 犬小哈 (微信号: 小哈学Java)
* @site 个人网站: www.exception.site
* @date 2019/4/15
* @time 下午9:12
* @discription
**/
public class User {

/**
* 姓名
*/
private String name;
/**
* 描述
*/
private String desc;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
}
}
@@ -0,0 +1 @@

@@ -0,0 +1,16 @@
package site.exception.springbootwebfluxhello;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringBootWebfluxHelloApplicationTests {

@Test
public void contextLoads() {
}

}

0 comments on commit 516e404

Please sign in to comment.