Skip to content

dewaldmienie/java-spring-boot-mongodb-starter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quick Start Java & MongoDB Project

Supported versions:

  • Java 8 to 15
  • Spring boot 2.4.2
  • MongoDB 4.4.3
  • MongoDB Java driver 4.1.1
  • Maven 3.6.3
  • Swagger 3.0.0

MongoDB Atlas

Commands

  • Start the server in a console with mvn spring-boot:run.
  • If you add some Unit Tests, you would start them with mvn clean test.
  • You can start the end to end tests with mvn clean integration-test.
  • You can build the project with : mvn clean package.
  • You can run the project with the fat jar and the embedded Tomcat: java -jar target/java-spring-boot-mongodb-starter-1.0.0.jar but I would use a real tomcat in production.

Swagger 3

Features showcase

This project showcases several features of MongoDB:

  • MongoDB multi-document ACID transactions for 3 functions. See MongoDBPersonRepository.saveAll().
  • MongoDB Aggregation pipeline. See MongoDBPersonRepository.getAverageAge().
  • Implementation of basic CRUD queries. See MongoDBPersonRepository.java.
  • MongoDB typed collection with automatic mapping to POJOs using codecs: See ConfigurationSpring.java.
  • How to manipulate correctly ObjectidId across, the REST API, the POJOs and the database itself. See the main trick in Person.java.

And some other cool stuff:

  • You can change the default Spring Boot logo by adding a banner.txt file in your properties.
  • You don't have to use Spring Data MongoDB. The MongoDB driver is more flexible and already provides everything you need to code efficiently and optimise your queries correctly.

Author

  • Maxime Beugnet @ MongoDB.

About

MongoDB Blog Post: REST APIs with Java, Spring Boot and MongoDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%