Book Image

Full Stack Development with Spring Boot and React - Third Edition

By : Juha Hinkula
Book Image

Full Stack Development with Spring Boot and React - Third Edition

By: Juha Hinkula

Overview of this book

Getting started with full stack development can be daunting. Even developers who are familiar with the best tools, such as Spring Boot and React, can struggle to nail the basics, let alone master the more advanced elements. If you’re one of these developers, this comprehensive guide covers everything you need! This updated edition of the Full Stack Development with Spring Boot 2 and React book will take you from novice to proficient in this expansive domain. Taking a practical approach, this book will first walk you through the latest Spring Boot features for creating a robust backend, covering everything from setting up the environment and dependency injection to security and testing. Once this has been covered, you’ll advance to React frontend programming. If you’ve ever wondered about custom Hooks, third-party components, and MUI, this book will demystify all that and much more. You’ll explore everything that goes into developing, testing, securing, and deploying your applications using all the latest tools from Spring Boot, React, and other cutting-edge technologies. By the end of this book, you'll not only have learned the theory of building modern full stack applications but also have developed valuable skills that add value in any setting.
Table of Contents (22 chapters)
1
Part 1: Backend Programming with Spring Boot
7
Part 2: Frontend Programming with React
12
Part 3: Full Stack Development

Understanding Maven

Apache Maven is a software project management tool that makes the software development process simpler and also unifies the development process.

Important Note

You can also use another project management tool called Gradle with Spring Boot, but in this book, we will focus on using Maven.

The basis of Maven is the Project Object Model (POM). The POM is a pom.xml file that contains basic information about a project. There are also all the dependencies that Maven should download to be able to build a project.

Basic information about a particular project can be found at the beginning of the pom.xml file, which defines—for example—the version of the application, the packaging format, and so on. The minimum version of the pom.xml file should contain the following:

  • project root
  • modelVersion
  • groupIdIdentifier (ID) of the project group
  • artifactId—ID of the project (artifact)
  • version—Version of the project (artifact)

Dependencies are defined in the dependencies section, as shown in the following pom.xml code:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
<groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent
             </artifactId>
        <version>2.5.2</version>
        <relativePath/> <!-- lookup parent from  
                 repository -->
    </parent>
    <groupId>com.packt</groupId>
    <artifactId>cardatabase</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>cardatabase</name>
    <description>Demo project for Spring Boot
          </description>
    <properties>
   <java.version>11</java.version>
    </properties>
    <dependencies>
    <dependency>
              
         <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web
                    </artifactId>
        </dependency>
        <dependency>  
          <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools
                    </artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
                
          <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test
                    </artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                
         <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-maven-plugin
                      </artifactId>
            </plugin>
        </plugins>
    </build>
</project>

Maven is normally used from the command line, but Eclipse contains embedded Maven, and that handles all the Maven operations we need. Therefore, we are not focusing on Maven command-line usage here. The most important thing is to understand the structure of the pom.xml file and how to add new dependencies to it. We will learn how to add dependencies using Spring Initializr in the next section. Later in this book, we will also add new dependencies manually to the pom.xml file.

In the next section, we will create our first Spring Boot project and see how we can run it using the Eclipse IDE.