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

Demo for Spring Boot 3(`master` branch)/2(other branches) and Spring Cloud microservices with distributed configuration (Spring Cloud Config), service discovery (Eureka), API gateway (Spring Cloud Gateway, Zuul), Swagger/OpenAPI documentation (Springdoc), logs correlation using Spring Cloud Sleuth/Micrometer OTEL and many more

NotificationsYou must be signed in to change notification settings

piomin/sample-spring-microservices-new

Repository files navigation

CircleCI

SonarCloudBugsCoverageLines of Code

In this project I'm demonstrating you the most interesting features ofSpring Cloud Project for building microservice-based architecture.


I'm publishing on my blog and maintaining example repositories just as a hobby. But if you feel it's worth donating:

ko-fi

Getting Started

Currently you may find here some examples of microservices implementation using different projects from Spring Cloud. All the examples are divided into the branches and described in a separated articles on my blog. Here's a full list of available examples:

  1. (This example has been update to the latest version of Spring Cloud without Zuul) Using Spring Cloud NetflixEureka as a discovery server,Zuul as a gateway,OpenFeign for communication and Spring Cloud Config Server. The example is available in the branchmaster. A detailed guide may be find in the following article:Quick Guide to Microservices with Spring Boot 2.0, Eureka and Spring Cloud
  2. Using Spring Cloud AlibabaNacos as a discovery and configuration server,Zuul andOpenFeign. The example is available in the branchalibaba. A detailed guide may be find in the following article:Microservices with Spring Cloud Alibaba
  3. Using Spring Cloud with Spring Boot support forGraphQL for building microservices,Apollo for inter-service communication andEureka as a discovery server. The example is available in the branchgraphql. A detailed guide may be find in the following article:GraphQL – The Future of Microservices?
  4. Using Spring Boot and partially Spring Cloud for building microservices deployed onOpenShift withSource-2-Image mechanism. The example is available in the branchopenshift. A detailed guide may be find in the following article:Running Java Microservices on OpenShift using Source-2-Image
  5. UsingTrampoline for managing group of Spring Boot microservices locally. The example is available in the branchtrampoline. A detailed guide may be find in the following article:Managing Spring Boot apps locally with Trampoline
  6. Using Spring Boot 3, Micrometer Tracing and Springdoc for building microservices with Spring Cloud. A detailed guide may be found in the following article:Microservices with Spring Boot 3 and Spring Cloud

Usage

Build the apps with images (we need ji forconfig-service since it containscurl):

$ mvn clean package -Pbuild-image

Then run all the containers withdocker-compose:

$ docker-compose up

Run Locally

To run locally. Microservices are exposed on dynamic ports, so you can safely run them all on the same workstation.

You can run Zipkin. However, it is not necessary:

docker run -d --name zipkin openzipkin/zipkin -p 9411:9411

Begin withconfig-service:

cd config-servicemvn spring-boot:run

Then, go todiscovery-service:

cd config-servicemvn spring-boot:run

Then, go run three microservices:employee-service,department-service, andorganization-service, e.g.:

cd employee-servicemvn spring-boot:run

Finally, rungateway-service:

cd gateway-servicemvn spring-boot:run

By default, Eureka is running on8061 port, and gateway is exposed under8060 port.
You can access global Swagger UI:http://localhost:8060/swagger-ui.html and switch between services. More details in the articles above.

In the most cases you need to have Maven and JDK8+. In the fourth example with OpenShift you will have to runMinishift on your machine. The best way to run the sample applications is with IDEs like IntelliJ IDEA or Eclipse.

Architecture

Our sample microservices-based system consists of the following modules:

  • gateway-service - a module that Spring Cloud Netflix Zuul for running Spring Boot application that acts as a proxy/gateway in our architecture.
  • config-service - a module that uses Spring Cloud Config Server for running configuration server in thenative mode. The configuration files are placed on the classpath.
  • discovery-service - a module that depending on the example it uses Spring Cloud Netflix Eureka or Spring Cloud Netlix Alibaba Nacos as an embedded discovery server.
  • employee-service - a module containing the first of our sample microservices that allows to perform CRUD operation on in-memory repository of employees
  • department-service - a module containing the second of our sample microservices that allows to perform CRUD operation on in-memory repository of departments. It communicates with employee-service.
  • organization-service - a module containing the third of our sample microservices that allows to perform CRUD operation on in-memory repository of organizations. It communicates with both employee-service and organization-service.

The following picture illustrates the architecture described above.


About

Demo for Spring Boot 3(`master` branch)/2(other branches) and Spring Cloud microservices with distributed configuration (Spring Cloud Config), service discovery (Eureka), API gateway (Spring Cloud Gateway, Zuul), Swagger/OpenAPI documentation (Springdoc), logs correlation using Spring Cloud Sleuth/Micrometer OTEL and many more

Topics

Resources

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp