Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Templates to create a Java Spring Boot microservices architecture with MongoDB

License

NotificationsYou must be signed in to change notification settings

mongodb-developer/microservices-architecture-mongodb

Repository files navigation

Important: This repository is no longer actively maintained.

This repository contains a set of templates to help you create a Java Spring Boot microservices architecture with MongoDB.

In this repo you'll find:

  • A config-server on port 8888
  • A service-registry on port 8761
  • An api-gateway on port 8080
  • Two microservices:
    • company-service on port 8081
    • employee-service on port 8082

Prerequisites

  • Docker (for local ephemeral MongoDB nodes or you can use MongoDB Atlas)
  • Java 21
  • Maven 3.6.3+

Getting Started

MongoDB

Microservices are supposed to be independent of each others. For this reason, we need two MongoDB instances: one for each microservice.

With Docker

The following script will start two local single node replica set nodes on port 27017 and 27018.

./1_docker-start-mongodb.sh

When you are done:

./3_docker-stop-mongodb.sh

With MongoDB Atlas

You can create two tests clusters on MongoDB Atlas and overwrite the default MongoDB URIs before starting the two microservices.

For thecompany_service use:

export MONGODB_URI_1="ATLAS_URI_HERE"

For theemployee_service use:

export MONGODB_URI_2="ATLAS_URI_HERE"

Start Spring Boot projects

Open five terminals: one for each folder.

Before we start the microservices, we need to retrieve theirconfig repository:

git clone git@github.com:mongodb-developer/microservices-architecture-mongodb-config-repo.git

Update the fileconfig-server/src/main/resources/application.properties so this property points to the config repo.

spring.cloud.config.server.git.uri=${HOME}/Work/microservices-architecture-mongodb-config-repo

Now we can start the Spring Boot projects.

Start with theconfig-server as the microservices need this one running to be able to retrieve their configuration.

cd config-servermvn clean spring-boot:run
cd service-registrymvn clean spring-boot:run
cd company-serviceexport MONGODB_URI_1="ATLAS_URI_HERE"# optionalmvn clean spring-boot:run
cd employee-serviceexport MONGODB_URI_2="ATLAS_URI_HERE"# optionalmvn clean spring-boot:run
cd api-gatewaymvn clean spring-boot:run

Test the REST APIs

Theapi-gateway running on port 8080 can distribute the queries to the relevant microservices.

You can test all the APIs using the script:

./2_api-tests.sh

Note that the script is only targeting the port 8080 of the api-gateway.

About

Templates to create a Java Spring Boot microservices architecture with MongoDB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp