Я пытаюсь использовать WebFlux.fn.
Я написал веб-контроллер, и он работает.
@RestController
@RequestMapping(path = "/api/v1/employees")
public class EmployeesController {
@RequestMapping(method = GET, path = "/{id:.+}", produces = APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> read(
@PathVariable(name = "id) String id) {
}
@ResponseStatus(NO_CONTENT)
@RequestMapping(method = PUT, path = "/{id:.+}", consumes = APPLICATION_JSON_VALUE)
public void updated(@PathVariable(name = "id") String id,
@RequestBody Employee entity) {
}
@ResponseStatus(NO_CONTENT)
@RequestMapping(method = DELETE, path = "/{id:.+}")
public void delete(@PathVariable(name = "id") String id) {
}
}
И я также написал Reactive Web controller, и он тоже работает.
@RestController
@RequestMapping(path = "/api/v1/employees/reactive")
public class EmployeesReactiveController {
@RequestMapping(method = GET, path = "/{id:.+"}, produces = APPLICATION_JSON_VALUE)
public Mono<Employee> read(
@PathVariable(name = "id") String id) {
}
@ResponseStatus(NO_CONTENT)
@RequestMapping(method = PUT, path = "/{id:.+}", consumes = APPLICATION_JSON_VALUE)
public Mono<Boolean> updated(
@PathVariable(name = PATH_NAME_EMPLOYEE_ID) String id,
@RequestBody Employee entity) {
}
@ResponseStatus(NO_CONTENT)
@RequestMapping(method = DELETE, path = "/{id:.+}")
public Mono<Long> delete(@PathVariable(name = "id") String id) {
}
}
И я застрял с версией WebFlux.fn.
@Configuration
public class EmployeesReactiveFnConfig {
@Bean
public RouterFunction<ServerResponse> employeesRouterFunction(
EmployeesReactiveFnHandler handler) {
return route(GET("/api/v1/employees/reactive/fn/{id:.+}"), handler::read);
}
}
@Component
public class EmployeesReactiveFnHandler {
public Mono<ServerResponse> read(@NotBlank String id) {
}
public Mono<ServerResponse> read(ServerRequest request) {
return read(request.pathVariable("id"));
}
}
Кажется, что эти два класса признаны Spring.
...DefaultListableBeanFactory - Creating shared instance of singleton bean 'employeesReactiveFnConfig'
...DefaultListableBeanFactory - Creating shared instance of singleton bean 'employeesReactiveFnHandler'
Всякий раз, когда я пытался, я получал это.
o.s.s.w.u.m.AntPathRequestMatcher - Request '/api/v1/employees/reactive/fn/......' matched by universal pattern '/**'
o.s.security.web.FilterChainProxy - /api/v1/employees/reactive/fn/...... has an empty filter list
o.s.web.servlet.DispatcherServlet - GET "/api/v1/employees/reactive/fn/......", parameters={}
o.s.w.s.h.SimpleUrlHandlerMapping - Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
o.s.w.s.r.ResourceHttpRequestHandler - Resource not found
o.s.web.servlet.DispatcherServlet - Completed 404 NOT_FOUND
o.s.s.w.u.m.AntPathRequestMatcher - Request '/error' matched by universal pattern '/**'
o.s.security.web.FilterChainProxy - /error has an empty filter list
o.s.web.servlet.DispatcherServlet - "ERROR" dispatch for GET "/error", parameters={}
o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#error(HttpServletRequest)
o.s.w.s.m.m.a.HttpEntityMethodProcessor - Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]
o.s.w.s.m.m.a.HttpEntityMethodProcessor - Writing [{timestamp=Fri Mar 20 18:54:24 KST 2020, status=404, error=Not Found, message=No message available, (truncated)...]
o.s.web.servlet.DispatcherServlet - Exiting from "ERROR" dispatch, status 404
Мое текущее дерево зависимостей выглядит следующим образом. (Некоторые для краткости сняты)
>mvn dependency:tree | grep springframework
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.2.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:5.2.4.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:5.2.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-actuator:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework:spring-context:jar:5.2.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-aop:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-aop:jar:5.2.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-beans:jar:5.2.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:2.2.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-orm:jar:5.2.4.RELEASE:compile
[INFO] | \- org.springframework:spring-aspects:jar:5.2.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-redis:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.data:spring-data-redis:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-keyvalue:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework:spring-oxm:jar:5.2.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-context-support:jar:5.2.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-redis-reactive:jar:2.2.5.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-hateoas:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-web:jar:2.2.5.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.5.RELEASE:compile
[INFO] | | \- org.springframework:spring-webmvc:jar:5.2.4.RELEASE:compile
[INFO] | \- org.springframework.hateoas:spring-hateoas:jar:1.0.3.RELEASE:compile
[INFO] | \- org.springframework.plugin:spring-plugin-core:jar:2.0.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-security:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.security:spring-security-config:jar:5.2.2.RELEASE:compile
[INFO] | \- org.springframework.security:spring-security-web:jar:5.2.2.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:5.2.3.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.2.5.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:2.2.5.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.2.5.RELEASE:test
[INFO] | +- org.springframework:spring-core:jar:5.2.4.RELEASE:compile
[INFO] | | \- org.springframework:spring-jcl:jar:5.2.4.RELEASE:compile
[INFO] | +- org.springframework:spring-test:jar:5.2.4.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-webflux:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-json:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-reactor-netty:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-validation:jar:2.2.5.RELEASE:compile
[INFO] | +- org.springframework:spring-web:jar:5.2.4.RELEASE:compile
[INFO] | +- org.springframework:spring-webflux:jar:5.2.4.RELEASE:compile
[INFO] +- org.springframework.data:spring-data-envers:jar:2.2.5.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-test:jar:5.3.0.RELEASE:test
[INFO] | \- org.springframework.security:spring-security-core:jar:5.3.0.RELEASE:compile
[INFO] | \- org.springframework.boot:spring-boot-starter-data-rest:jar:2.2.4.RELEASE:runtime
[INFO] | \- org.springframework.data:spring-data-rest-webmvc:jar:3.2.4.RELEASE:runtime
[INFO] | \- org.springframework.data:spring-data-rest-core:jar:3.2.4.RELEASE:runtime