Setting up a Spring-MongoDB project

We need to create a simple web application project using Maven.

  1. Execute the following command in your Maven command prompt:
    mvn archetype:generate -DgroupId=com.packtpub.spring -DartifactId=spring-mongo -DarchetypeArtifactId=maven-archetype-webapp
    
  2. Create a simple Maven project with a web application archetype. Add the latest 4.0.2.RELEASE spring dependency.
  3. The following is an extract from the pom.xml file. These are the mandatory dependencies to be added to the pom.xml file.
    <!-- Spring dependencies --> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>2.9.1</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> ...

Get Mastering Spring Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.