ARTICLE AD BOX
I am new to Java and Spring Boot. I am building a small CRUD app to learn about JPA and the H2 database.
This is my POM file:
<?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>4.0.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.robertforpresent</groupId> <artifactId>spring_api</artifactId> <version>0.0.1-SNAPSHOT</version> <name>spring_api</name> <description>Spring API</description> <url/> <licenses> <license/> </licenses> <developers> <developer/> </developers> <scm> <connection/> <developerConnection/> <tag/> <url/> </scm> <properties> <java.version>25</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-h2console</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webmvc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <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.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </path> </annotationProcessorPaths> <source>16</source> <target>16</target> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <addResources>true</addResources> <excludes> <exclude> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>-XX:+EnableDynamicAgentLoading</argLine> </configuration> </plugin> </plugins> </build> </project>When I annotate a test with DataJPATest, it cannot resolve it. I tried with Claude Code, a new spring.initializer pom (with JPA, test and H2 dependencies) as well as searching the Web manually.
I found import statements like:
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;However, the orm does not exist. I did invalidate caches (I use IntelliJ), deleted .m2/org/springframework/boot and did several mvn clean install. No solution yet.
I fear I am missing something VERY obvious, due to my little hands-on experience with either Java or Maven.
I found this: DataJpaTest and AutoConfigureTestDatabase in Spring Boot 4.0.0
but here "jpa.test" (test) is missing.
