- [Instructor] Okay, let's get started coding. The first component we will build is the controller configuration file. First, let's create the annotated config class for our controller then we will define any Spring beans and other configuration we need. All right, let's jump into IntelliJ and get started. Okay, first off, let's right-click on the base package, go to new, and then create a new package.
Let's name it config. Now, let's right click on the config package, go to new and create a new Java Class. Let's name it ApiConfig. First off, let's create a new method called Object Mapper that returns an instance of object mapper.
Now, let's use the keyboard shortcut Alt plus Enter to import the Object Mapper class. Now, let's create a new instance of the Object Mapper using the object mapper parameter list constructor. Now, let's configure the object mapper. Let's go ahead and set the de-serialization feature fail on unknown properties to false.
This way we don't have to define every single property in a Json to map it to an object. Then let's go ahead and return that object. Okay let's fix a typo in the method declaration and then finally let's add a bean annotation to the method.
Next let's create an object writer method that returns a type of object writer. Object writer will accept the object mapper bean as a parameter. Now let's call the method writer with default pretty printer from the object mapper to create a object writer instance.
Then let's go ahead and return that object writer. Let's add a bean annotation. Okay the final bean we will define is a web client. Let's go a head and create a web client method that returns an instance of web client.
Let's import web client, then let's use the web client builder. And call the client connector method. Passing in a new instance of the reactor client HTTP connector. And then finally let's call the build method.
Now let's go ahead and return that instance of web client. Finally let's not forget the bean annotation. Okay let's press command S to save and that should be it, our API is now configured.
- Project Reactor and Reactive Core
- Spring WebFlux
- Reactive Spring Data with MongoDB
- Bootstrapping a reactive web app with Spring Boot 2
- Writing reactive Spring controllers
- Working with Spring reactive data
- Spring reactive unit testing
- Writing tests using the WebTestClient