piomin/sample-spring-microservices-new
Tentang
Demo mikrolayanan Spring Boot dan Spring Cloud dengan konfigurasi terdistribusi (Spring Cloud Config), penemuan layanan (Eureka), gateway API (Spring Cloud Gateway, Zuul), dokumentasi Swagger/OpenAPI (Springdoc), korelasi log menggunakan Spring Cloud Sleuth/Micrometer OTEL, dan banyak lagi.
Pengembangan web dan aplikasiPertumbuhan bintang terukur
- dalam 24 jam
- 0
- dalam 7 hari
- +2
- dalam 15 hari
- +2
- dalam 1 bulan
- +3
Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.
README.md
AsliMicroservices with Spring Cloud Advanced Demo Project 
In this project I'm demonstrating you the most interesting features of Spring 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:
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:
- (This example has been updated to the latest version of Spring Cloud, with Spring Cloud Gateway instead of Zuul) Using Spring Cloud Netflix Eureka as a discovery server, Spring Cloud Gateway as a gateway, OpenFeign for communication and Spring Cloud Config Server. The example is available in the branch master. A detailed guide may be find in the following article: Quick Guide to Microservices with Spring Boot 2.0, Eureka and Spring Cloud
- Using Spring Cloud Alibaba Nacos as a discovery and configuration server, Zuul and OpenFeign. The example is available in the branch alibaba. A detailed guide may be find in the following article: Microservices with Spring Cloud Alibaba
- Using Spring Cloud with Spring Boot support for GraphQL for building microservices, Apollo for inter-service communication and Eureka as a discovery server. The example is available in the branch graphql. A detailed guide may be find in the following article: GraphQL – The Future of Microservices?
- Using Spring Boot and partially Spring Cloud for building microservices deployed on OpenShift with Source-2-Image mechanism. The example is available in the branch openshift. A detailed guide may be find in the following article: Running Java Microservices on OpenShift using Source-2-Image
- Using Trampoline for managing group of Spring Boot microservices locally. The example is available in the branch trampoline. A detailed guide may be find in the following article: Managing Spring Boot apps locally with Trampoline
- 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 (config-service and discovery-service are built with Jib on a JDK image, since the healthchecks in docker-compose need curl):
$ mvn clean package -Pbuild-image
Then run all the containers with docker-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 -p 9411:9411 openzipkin/zipkin
Begin with config-service:
cd config-service
mvn spring-boot:run
Then, go to discovery-service:
cd discovery-service
mvn spring-boot:run
Then, go run three microservices: employee-service, department-service, and organization-service, e.g.:
cd employee-service
mvn spring-boot:run
Finally, run gateway-service:
cd gateway-service
mvn spring-boot:run
By default, Eureka is running on 8061 port, and gateway is exposed under 8060 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 JDK 25. In the fourth example with OpenShift you will have to run Minishift 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 uses Spring Cloud Gateway 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 the
nativemode. 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.

Jelajahi proyek terkait
Memuat…