Java Magazine, Mar/Apr 2018
Reactive Spring Setting up a REST API In part 1 I built a reactive app with the Spring Framework Now Ill provide access to it by quickly implementing a REST API ORACLE COM JAVAMAGAZINE MARCH APRIL 2018 81 reactive programming In the previous issue of this magazine I presented part 1 of this two part series In it I explained the reactive components that are available in Spring Framework 50 and I built a simple project to serve up book data Now that Ive got data in the data source I will stand up a REST API Ill use Spring WebFlux a brand new reactive web runtime and component model Spring WebFlux does not depend on the Java Servlet specification It can work independently with a Netty based web server It is designed from the bottom up to work with Publisher T instances To follow along youll need just a little Spring background although youll be well served by quickly reading or reviewing the previous article in this series Spring WebFlux With Spring WebFlux I can use Spring model view controller MVC style controllers as shown in Listing 1 Listing 1 A Spring MVC style REST API package com example libraryservice import org springframework context annotation Profile import org springframework web bind annotation GetMapping import org springframework web bind annotation PathVariable import org springframework web bind annotation RestController import reactor core publisher Flux JOSH LONG
You must have JavaScript enabled to view digital editions.