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


