Creating a project using Spring Initializr

Let's start with creating a new project using Spring Initializr (http://start.spring.io/). The following screenshot shows the details:

A few things to note are as follows:

  • Group: com.mastering.spring.reactive
  • Artifact: spring-reactive-example
  • Dependencies : ReactiveWeb (to build a reactive web application) and DevTools (for auto-reload when the application code is changed)

Download the project and import it into your IDE as a Maven project.

Important dependencies in the pom.xml file are shown as follows:

    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>

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

The spring-boot-starter-webflux dependency is the most important dependency for Spring Web Reactive. A quick look at the pom.xml file of spring-boot-starter-webflux reveals the building blocks of Spring Reactive--spring-webflux, spring-web, and spring-boot-starter-reactor-netty.

Netty is the default embedded reactive server. The following snippet shows the dependencies:

    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-reactor-netty</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
</dependency>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset