Reader small image

You're reading from  Full Stack Development with Spring Boot and React - Third Edition

Product typeBook
Published inApr 2022
Reading LevelIntermediate
PublisherPackt
ISBN-139781801816786
Edition3rd Edition
Languages
Right arrow
Author (1)
Juha Hinkula
Juha Hinkula
author image
Juha Hinkula

Juha Hinkula is a software development lecturer at Haaga-Helia University of Applied Sciences in Finland. He received an MSc degree in Computer Science from the University of Helsinki and he has over 17 years of industry experience in software development. Over the past few years, he has focused on modern full stack development. He is also a passionate mobile developer with Android-native technology, and also uses React Native.
Read more about Juha Hinkula

Right arrow

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.

Previous PageNext Page
You have been reading a chapter from
Full Stack Development with Spring Boot and React - Third Edition
Published in: Apr 2022Publisher: PacktISBN-13: 9781801816786
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Juha Hinkula

Juha Hinkula is a software development lecturer at Haaga-Helia University of Applied Sciences in Finland. He received an MSc degree in Computer Science from the University of Helsinki and he has over 17 years of industry experience in software development. Over the past few years, he has focused on modern full stack development. He is also a passionate mobile developer with Android-native technology, and also uses React Native.
Read more about Juha Hinkula