Spring Boot build failure traced to JPA dependencies in a MongoDB project
A developer reopened an old Spring Boot project and encountered 20 compilation errors caused by a mismatch between the code and the project's dependencies. The pom.xml was configured with the MongoDB starter, while the code used JPA annotations such as @Entity and JpaRepository, which belong to the SQL-based spring-boot-starter-data-jpa dependency. Fixing the annotations to their MongoDB equivalents and changing the user ID type from Long to String resolved the compilation errors. The app still failed to start due to a duplicate key error in MongoDB, caused by existing documents with null username fields conflicting with a new unique index. Switching to fresh collection names in the @Document annotations cleared the conflict and allowed the application to start successfully.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in