If you need to render HTML for web and stand alone applications and want to have reactive Spring Webflux as backend, this technical post is for you, because this time we will go through the process to create a basic project in Spring Webflux with Thymeleaf. NOTE: If you need to know what tools you need to have installed in your computer in order to create a Spring Boot basic project, please refer my previous post: Spring Boot
[Read More]
Spring Webflux Security Database
This post walks you through the process of creating a simple registration and login example with Spring WebFlux Security using MongoDB database. Please read this previous Spring Webflix Security before conitnue with this information. Let’s add MongoDB and Lombok dependencies to the build.gradle file
implementation('org.springframework.boot:spring-boot-starter-data-mongodb-reactive') compileOnly('org.projectlombok:lombok') annotationProcessor('org.projectlombok:lombok') Lombok is a great tool to avoid boilerplate code, for knowing more please go here. Next step, we need to change Spring security Java config class in order to add userDetailsService, so that we can implement database access functionality.
[Read More]
Spring Webflux Security
Spring Security is a powerful and highly customizable authentication and access-control framework. In this technical post we will go through the process to integrate Spring Security to Spring Reactive Webflux. If you want to know more about how to create a Spring Webflux application please go to my previous post getting started with Spring Webflux here. Let’s begin creating a new Spring Boot project with Webflux, Lombok, Spring Security and Thymeleaf:
[Read More]
Spring Webflux Client
We covered the reactive web server in the previous Spring Boot Server; this time, we will see the client side. Let’s start creating a new project with Webflux and Lombok as dependencies:
spring init --dependencies=webflux,lombok --build=gradle --type=gradle-project --language=java client Here is the complete build.gradle file generated:
plugins { id 'java' id 'org.springframework.boot' version '3.0.6' id 'io.spring.dependency-management' version '1.1.0' } group = 'com.jos.dem.webflux' version = '0.0.1-SNAPSHOT' sourceCompatibility = 17 configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation('org.
[Read More]
Spring Webflux Server
This post walks you through the process of creating endpoints using Spring Webflux. Please read this previous Spring Webflux Basics post before continuing with this information. We are going to use @RestController to serve data from our PersonRepository. Let’s consider the following example:
package com.jos.dem.webflux.controller; import reactor.core.publisher.Mono; import reactor.core.publisher.Flux; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import com.jos.dem.webflux.model.Person; import com.jos.dem.webflux.repository.PersonRepository; import lombok.extern.slf4j.Slf4j; @Slf4j @RestController @RequiredArgsConstructor public class PersonController { private final PersonRepository personRepository; @GetMapping("/persons") public Flux<Person> findAll() { log.
[Read More]
Getting Started with Spring Webflux
Spring Boot now embraces reactive programming, a non-blocking asynchronous and event-driven application. Spring Framework uses Reactor internally for its own reactive support. The reactor is a Reactive Streams implementation that further extends the primary Publisher contract with Flux and Mono. NOTE: If you need to know what tools you need to have installed in your computer in order to create a Spring Boot basic project, please refer to my previous post: Spring Boot.
[Read More]
Spring Boot Publishing an Artifactory Library
In this technical post, we will go over the process of publishing a Spring Boot library to JFrog. NOTE: If you want to know more about creating a Spring application, please go to my previous post getting started with Spring Boot here. Let’s begin creating a new Spring Boot project with Web and Lombok.
spring init --dependencies=web,lombok --build=gradle --language=java juice-restclient Now, let’s activate Maven publish plugin:
apply plugin: 'maven-publish' And add our Gradle publishing task definition.
[Read More]
Spring Boot Testing the Web Layer
In this technical post, we will go through the process of testing a web layer using MockMvc. MockMvc helps to test Spring Boot controllers with auto-configuration, if you want to know more about how to create Spring Boot application please go to my previous post getting started with Spring Boot here. As the project target to test we will use Spring Boot Swagger. Please consider this controller.
package com.josdem.swagger.controller; import com.
[Read More]
Spring Boot Retrofit2 Cucumber & Junit5
Retrofit is a powerful webclient for Java and Android, allows you to configure data serialization converters and internally uses OkHttp for HTTP requests. This time we will review how to use Retrofit along with Cucumber and Junit 5 in order to consume a public REST API GitHub API v3. Let’s start creating a new Spring Boot project with Webflux as dependency:
spring init --dependencies=webflux --build=gradle --language=java retrofit-workshop NOTE: If you need to know what tools you need to have installed in your computer in order to create a Spring Boot basic project, please refer my previous post: Spring Boot
[Read More]
Spring Boot Profiles
In this technical post, we’ll discuss how to manage different properties files when we run a Spring Boot application, this is helpful when you need to manage several environments. NOTE: If you need to know what tools you need to have installed in your computer in order to create a Spring Boot basic project, please refer my previous post: Spring Boot
Then execute this command in your terminal.
spring init --dependencies=webflux --build=gradle --language=java spring-boot-profiles This is the build.
[Read More]