liveBook · Manning

Project object model

As explained in Java Persistence with Spring Data and Hibernate epub

pom.xml is the Maven Project Object Model file that declares a project's metadata, dependencies, and build configuration.

The Project Object Model is Maven’s pom.xml file: the project descriptor that identifies an application and declares the dependencies needed to build and run it. Spring Initializr generates this file when creating Spring Boot projects, leaving application-specific runtime settings to application.properties. section 4.2 section 20.2

A persistence-oriented pom.xml commonly declares:

  • Spring Data JPA through spring-boot-starter-data-jpa for database persistence. section 20.2
  • A MySQL driver through mysql-connector-java for database access. section 20.2
  • Bean Validation through spring-boot-starter-validation when entity fields require validation. section 20.2
  • Spring Web and Spring Data REST when the application exposes repository-backed HTTP resources. section 16.2

Spring Data JPA project

A generated project identifies itself with groupId com.manning.javapersistence, artifactId springdatajpa, version 0.0.1-SNAPSHOT, name, and description. Its parent uses spring-boot-starter-parent version 2.7.0, while dependencies add Spring Data JPA and the MySQL driver. The resulting application can pair the POM with application.properties for database and JPA settings. section 4.2

Listing 20.1 The pom.xml Maven file
Path: Ch20/1 spring testing/pom.xml
 
   \1                                                         #1
       <groupId>org.springframework.boot</groupId>                      #1
       <artifactId>spring-boot-starter-data-jpa</artifactId>            #1
   </dependency>                                                        #1
   <dependency>                                                         #2
       <groupId>org.springframework.boot</groupId>                      #2
       <artifactId>spring-boot-starter-validation</artifactId>          #2
   </dependency>                                                        #2
   <dependency>                                                         #3
       <groupId>mysql</groupId>                                         #3
       <artifactId>mysql-connector-java</artifactId>                    #3
       <scope>runtime</scope>                                           #3
   </dependency>                                                        #3
   <dependency>                                                         #4
       <groupId>org.projectlombok</groupId>                             #4
       <artifactId>lombok</artifactId>                                  #4
       <optional>true</optional>                                        #4
   </dependency>                                                        #4
   <dependency>                                                         #5
       <groupId>org.springframework.boot</groupId>                      #5
       <artifactId>spring-boot-starter-test</artifactId>                #5
       <scope>test</scope>                                              #5
   </dependency>                                                        #5

Inspect the complete persistence-testing POM and its dependency choices. section 20.2

How Java Persistence with Spring Data and Hibernate epub covers it

How deep it goes
Defines project metadata and dependency choices through concrete generated POM listings, but defers runtime database settings to application.properties.
Examples
Uses Spring Initializr projects for Spring Data JPA, persistence testing, and Spring Data REST with MySQL.
What you can do after
Operate Spring Initializr and Maven projects by selecting dependencies for a concrete Spring Boot persistence or REST application.
How it connects
Connects Maven with Spring Boot, Spring Data JPA, MySQL, Bean Validation, Spring Data REST, and application.properties.

Also explained in

Compare how 3 books explain project object model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Java Persistence with Spring Data and Hibernate epub. The section links point to the parts of the book it draws on.