第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定

route

return?RouterFunction.route(RequestPredicates.GET("/person/find/all"),

為啥我的這句話中route報錯,

代碼:

package?com.example.somefrist.config;

import?com.example.somefrist.domain.User;
import?com.example.somefrist.repository.UserRepository;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.context.annotation.Bean;
import?org.springframework.context.annotation.Configuration;
import?org.springframework.web.reactive.function.server.RequestPredicates;
import?org.springframework.web.reactive.function.server.RouterFunction;
import?org.springframework.web.reactive.function.server.ServerResponse;
import?reactor.core.publisher.Flux;

import?java.util.Collection;

/**
?*
?*
?*?路由器函數(shù)注釋
?*/

@Configuration
//類所處的對象是配置對象
public?class?RouterFunctionConfiguration?{

????/**
?????*?Servlet
?????*?請求接口??ServletRequest??或者?HttpServletRequest
?????*?響應(yīng)接口??ServletResponse??后者???HttpServletResponse
?????*
?????*?spring5.0重新定義了服務(wù)端的請求和響應(yīng)接口:
?????*?請求接口:ServerRequest
?????*?響應(yīng)接口:ServerResponse
?????*
?????*?既可以支持Servlet規(guī)范,也可以支持自定義,比如:Netty(Web?Server)
?????*
?????*
?????*?以本利:
?????*?定義GET請求,并且返回所有的用戶對象,??URI:/person/find/all
?????*
?????*
?????*?Flux是0-N個對象集合
?????*?Mono是?0-1?個對象集合
?????*
?????*?Reactive?中?Flux?或者??Mono??它是異步處理
?????*
?????*?集合對象基本上是同步處理(阻塞式)
?????*
?????*?Flux?或者?Mono?都是?Publisher,
?????*/
????@Bean
????@Autowired
????public?RouterFunction<ServerResponse>?personFindAll?(UserRepository?userRepository){




????????return?RouterFunction.route(RequestPredicates.GET("/person/find/all"),
????????????????request->{

????????????????????Collection<User>?users?=??userRepository.findAll();

????????????????????//返回所有用戶對象


????????????????????//Mono<ServerResponse>?response?=?null;
????????????????????Flux<User>?userFlux?=?Flux.fromIterable(users);
????????????????????//ServerResponse.ok().body(userFlux,?User.class);
????????????????????return?ServerResponse.ok().body(userFlux,?User.class);
????????????????});

????}

}


報錯原因

https://img1.sycdn.imooc.com//5b0b7bb00001c14010460078.jpg

正在回答

2 回答

https://img1.sycdn.imooc.com//5b0b7d850001aae608280104.jpg

這是運(yùn)行報錯的截圖

0 回復(fù) 有任何疑惑可以回復(fù)我~

這是maven的pom.xml

<?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>

????<groupId>com.example</groupId>
????<artifactId>somefrist</artifactId>
????<version>0.0.1-SNAPSHOT</version>
????<packaging>jar</packaging>

????<name>somefrist</name>
????<description>Demo?project?for?Spring?Boot</description>

????<parent>
????????<groupId>org.springframework.boot</groupId>
????????<artifactId>spring-boot-starter-parent</artifactId>
????????<version>2.0.2.RELEASE</version>
????????<relativePath/>?<!--?lookup?parent?from?repository?-->
????</parent>

????<properties>
????????<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
????????<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
????????<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>
????????<dependency>
????????????<groupId>org.apache.logging.log4j</groupId>
????????????<artifactId>log4j-core</artifactId>
????????????<version>2.0-beta4</version>
????????</dependency>
????????<dependency>
????????????<groupId>org.apache.httpcomponents</groupId>
????????????<artifactId>httpclient</artifactId>
????????????<version>4.3.6</version>
????????</dependency>
????????<dependency>
????????????<groupId>org.springframework</groupId>
????????????<artifactId>spring-webflux</artifactId>
????????????<version>5.0.6.RELEASE</version>
????????</dependency>
????</dependencies>

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


</project>


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
Spring Boot 2.0深度實踐-初遇Spring Boot
  • 參與學(xué)習(xí)       75479    人
  • 解答問題       221    個

Spring Boot 2.x/Web Flux/多模塊化項目實踐

進(jìn)入課程
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號