{"id":18398748,"url":"https://github.com/mongodb-developer/java-spring-boot-mongodb-starter","last_synced_at":"2025-05-12T14:47:25.138Z","repository":{"id":79559098,"uuid":"145867149","full_name":"mongodb-developer/java-spring-boot-mongodb-starter","owner":"mongodb-developer","description":"MongoDB Blog Post: REST APIs with Java, Spring Boot and MongoDB","archived":false,"fork":false,"pushed_at":"2024-07-27T13:39:47.000Z","size":55,"stargazers_count":96,"open_issues_count":0,"forks_count":82,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-26T09:11:13.582Z","etag":null,"topics":["mongodb","mongodb-driver","rest-api","showcases","spring-boot","swagger","template"],"latest_commit_sha":null,"homepage":"https://www.mongodb.com/blog/post/rest-apis-with-java-spring-boot-and-mongodb","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb-developer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-23T14:44:14.000Z","updated_at":"2025-01-13T14:04:39.000Z","dependencies_parsed_at":"2023-03-13T20:09:49.463Z","dependency_job_id":"ba19c663-db1c-4244-a0a1-8cc0d3495dc8","html_url":"https://github.com/mongodb-developer/java-spring-boot-mongodb-starter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fjava-spring-boot-mongodb-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fjava-spring-boot-mongodb-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fjava-spring-boot-mongodb-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb-developer%2Fjava-spring-boot-mongodb-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb-developer","download_url":"https://codeload.github.com/mongodb-developer/java-spring-boot-mongodb-starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238059009,"owners_count":19409607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mongodb","mongodb-driver","rest-api","showcases","spring-boot","swagger","template"],"created_at":"2024-11-06T02:24:15.036Z","updated_at":"2025-02-10T05:09:23.613Z","avatar_url":"https://github.com/mongodb-developer.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Quick Start: Java, Spring Boot \u0026 MongoDB Template\n\n## Blog Post\n\nThe code in this repository is discussed in [this blog post](https://www.mongodb.com/developer/code-examples/java/rest-apis-java-spring-boot/) in the [MongoDB Developer Center](https://www.mongodb.com/developer/).\n\n## Supported versions:\n\n- Java 21\n- Spring boot 3.2.2\n- MongoDB 7.0\n- MongoDB Java driver 4.11.1\n- Maven 3.8.7\n- OpenAPI 3\n\n## MongoDB Atlas\n\n- Get started with a Free Tier Cluster on [MongoDB Atlas](https://www.mongodb.com/cloud/atlas).\n- Read this blog post: [Quick Start - Getting your Free MongoDB Atlas Cluster](https://developer.mongodb.com/quickstart/free-atlas-cluster).\n- You will need to update the default MongoDB URI `spring.data.mongodb.uri` in the `application.properties` file or set an environment variable: `export MONGODB_URI=mongodb://localhost:27017`.\n\n## Commands\n\n- Start the server in a console with `mvn spring-boot:run`.\n- If you add some Unit Tests, you would start them with `mvn clean test`.\n- You can start the end-to-end tests with `mvn clean integration-test`.\n- You can build the project with : `mvn clean package`.\n- 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.\n\n## Project Loom \u0026 Virtual Threads\n\n- This project starter supports Virtual Threads thanks to:\n  - JDK 21\n  - Spring 3.2.0+.\n  - `spring.threads.virtual.enabled=true` in the `application.properties`\n\n## Swagger \u0026 OpenAPI 3\n- `springdoc-openapi-starter-webmvc-ui` library dependency is in the `pom.xml`.\n- No configuration required.\n- The Swagger UI can be seen at [http://localhost:8080/swagger-ui/index.html](http://localhost:8080/swagger-ui/index.html).\n- The JSON Open API documentation 3.0.1 is at [http://localhost:8080/v3/api-docs](http://localhost:8080/v3/api-docs).\n- The YAML Open API documentation 3.0.1 is at [http://localhost:8080/v3/api-docs.yaml](http://localhost:8080/v3/api-docs.yaml).\n- You can also try the entire REST API directly from the Swagger web interface!\n\n## Features showcase\nThis project showcases several features of MongoDB:\n\n- MongoDB multi-document ACID transactions for 3 functions. See `MongoDBPersonRepository.saveAll()`.\n- MongoDB Aggregation pipeline. See `MongoDBPersonRepository.getAverageAge()`.\n- Implementation of basic CRUD queries. See `MongoDBPersonRepository.java`.\n- MongoDB typed collection with automatic mapping to POJOs using codecs: See `ConfigurationSpring.java`.\n- How to manipulate correctly ObjectId across, the REST API, the POJOs and the database itself. See the main trick in `Person.java`.\n\nAnd some other cool stuff:\n- You can change the default Spring Boot logo by adding a banner.txt file in your properties.\n- 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.\n\n## Example API Calls\n\n```bash\ncurl -X 'POST' \\\n  'http://localhost:8080/api/person' \\\n  -H 'accept: */*' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n  \"firstName\": \"Maxime\",\n  \"lastName\": \"Beugnet\",\n  \"age\": 35,\n  \"address\": {\n    \"number\": 123,\n    \"street\": \"avenue des Champs-Elysées\",\n    \"postcode\": \"75000\",\n    \"city\": \"Paris\",\n    \"country\": \"France\"\n  },\n  \"insurance\": true,\n  \"cars\": [\n    {\n      \"brand\": \"Peugeot\",\n      \"model\": \"3008\",\n      \"maxSpeedKmH\": 280\n    }\n  ]\n}'\n```\n\n```bash\ncurl -X 'GET' 'http://localhost:8080/api/persons' -H 'accept: */*'\n```\n\n## Author\n\nMaxime Beugnet\n\n- maxime@mongodb.com\n- MaBeuLux88 on [GitHub](https://github.com/mabeulux88)\n- MaBeuLux88 in the [MongoDB Developer Community forum](https://www.mongodb.com/community/forums/u/MaBeuLux88/summary).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb-developer%2Fjava-spring-boot-mongodb-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb-developer%2Fjava-spring-boot-mongodb-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb-developer%2Fjava-spring-boot-mongodb-starter/lists"}