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
NotificationsYou must be signed in to change notification settings

el-moudni-hicham/microservices-spring-cloud-angular

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

 • Spring Cloud Gateway • Eureka Discovery • Open Feign Rest Client • Hystrix DashBoard

Project Class Diagram

Table of contents

Customer Service

Create a new Spring project :

project example

Selected dependencies

• Spring Web • Spring Data JPA • H2 Database• Rest Repositories • Lombok• Spring Boot DevTools• Eureka Discovery Client• Spring Boot Actuator

Application Configurationapplication.properties

spring.application.name=customer-servicespring.datasource.url=jdbc:h2:mem:customers-dbspring.cloud.discovery.enabled=true#management.endpoints.web.exposure.include=*server.port=8888

Steps :

1. CreateCustomer entity

packagema.enset.customermicroservice.entites;importjakarta.persistence.Entity;importjakarta.persistence.GeneratedValue;importjakarta.persistence.GenerationType;importjakarta.persistence.Id;importlombok.AllArgsConstructor;importlombok.Data;importlombok.NoArgsConstructor;importlombok.ToString;@Entity@Data@NoArgsConstructor@AllArgsConstructor@ToStringpublicclassCustomer {@Id@GeneratedValue(strategy =GenerationType.IDENTITY)privateLongid;privateStringname;privateStringemail;}

2. CreateCustomerRepository Spring Data based interface

packagema.enset.customermicroservice.repository;importma.enset.customermicroservice.entites.Customer;importorg.springframework.data.jpa.repository.JpaRepository;importorg.springframework.data.rest.core.annotation.RepositoryRestResource;@RepositoryRestResourcepublicinterfaceCustomerRepositoryextendsJpaRepository<Customer,Long> {}

3. Deploy Restful API of microservice with Spring Data Rest

4. Microservice test

Customers

project example

Find Customer By Id

project example

Actuator

project example

Actuator Health

project example

DatabaseH2

project example

Inventory Service

Application Configurationapplication.properties

spring.application.name=inventory-servicespring.datasource.url=jdbc:h2:mem:products-dbspring.cloud.discovery.enabled=trueserver.port=8889

Steps :

  1. CreateProduct entity
  2. CreateProductRepository Spring Data based interface
  3. Deploy Restful API of microservice with Spring Data Rest
  4. Microservice test

All Products
project example

Database

Gateway Service

Selected dependencies

• Gateway • Spring Boot Actuator• Hystrix • Eureka Discovery Client

1. Static routes configuration : application.yml / application.properties

application.properties

spring.application.name=gateway-servicespring.cloud.discovery.enabled=trueserver.port=8890

application.yml

spring:cloud:gateway:routes:        -id :r1uri :http://localhost:8888/predicates :            -Path= /customers/**        -id :r2uri :http://localhost:8889/predicates :            -Path= /products/**

Access to All Customers from Gateway
project example

Access to All Products from Gateway

2. Static routes configuration : Java Config Class

@BeanRouteLocatorrouteLocator(RouteLocatorBuilderbuilder){returnbuilder.routes()                .route("r1", (r) ->r.path("/customers/**").uri("http://localhost:8888/"))                .route("r2", (r) ->r.path("/products/**").uri("http://localhost:8889/"))                .build();    }

Access to All Customers from Gateway
project example

Access to All Products from Gateway

3. Eureka Discovery Service : Dynamic Routing

Eureka Discovery Service

Selected dependencies

• Eureka Server

EnableEurekaServer

@SpringBootApplication@EnableEurekaServerpublicclassEurekaDiscoveryApplication {publicstaticvoidmain(String[]args) {SpringApplication.run(EurekaDiscoveryApplication.class,args);    }}

application.properties

server.port=8761#dontregisterserveritselfasaclient.eureka.client.fetch-registry=false#Doesnotregisteritselfintheserviceregistry.eureka.client.register-with-eureka=false

Eureka Spring

Static routes configuration with Discovery Service

@BeanRouteLocatorrouteLocator(RouteLocatorBuilderbuilder){returnbuilder.routes()                .route("r1", (r) ->r.path("/customers/**").uri("lb://CUSTOMER-SERVICE"))                .route("r2", (r) ->r.path("/products/**").uri("lb://INVENTORY-SERVICE"))                .build();    }

Access to All Customers from Gateway
project example

Access to All Products from Gateway

Dynamic routes configuration with Discovery Service

@BeanDiscoveryClientRouteDefinitionLocatordefinitionLocator(ReactiveDiscoveryClientrdc,DiscoveryLocatorPropertiesdlp){returnnewDiscoveryClientRouteDefinitionLocator(rdc,dlp);    }

Access to All Customers from Gateway
project example

Access to All Products from Gateway

Billing Service

Selected dependencies

• OpenFeign • Spring HATEOAS

Service Test

Bill Complet Informations
project example

Bill Complet Informations
project example

Access to All Products from Gateway

II - Front End Part with Angular :

Link toFront End part.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp