Open cainawuha opened 4 years ago
The microservice should do one thing, and do that one thing well.
a set of microservices that together provide an application
Build a fully functioning REST API with persistence in RDBMS that can be inspected via a browser or a tool like Postman:
Setup MySQL, create a DB and verify connectivity. Write SQL to create the required tables. Setup DB migration to run the above SQL. Define classes for required JPA Entities and identify relationships between them. Define required Spring Data JPA Repositories. Write tests for Repositories against an in-memory database (H2). Wire the Repository to the already provided REST Controller.
RestTemplate allows you to consume a REST API programmatically from your code.
Eureka, created by Netflix, is responsible for the registration and discovery microservices. process: 1 creates a Eureka server use spring boot 2Create an entity called Dog. 3 Create a repository 4 Create a data.sql file now navigated to http://localhost:8080/dogs, can access microservices 5 Turn the microservice into a Eureka client: at port 8762 @EnableEurekaClient public class DogMicroserviceApplication { public static void main(String[] args) { SpringApplication.run(DogMicroserviceApplication.class, args); } }
6 spring.application.name=dog-service server.port=8762 eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/ 8761 is server eureka.client.service-url.default-zone=http://localhost:8761/eureka/
7 You should also be able to see the returned JSON from your Dog microservice at http://localhost:8762/dogs