Microservice: Use small independent components with well-defined boundaries to do one thing well.
一, spring cloud
Spring cloud provides config server, which has the function of external configuration in distributed system development.
The config server supports placing files in git or in the system file system. Different configuration files for different applications can be distinguished using the following formats:
/{application}/{profile}[/{label}] /{application}-{profile}.yml /{label}/{application}-{profile}.xml /{application}-{profile}.properties /{label}/{application}-{profile}.properties
Spring Cloud provides annotation @EnableConfigServer to enable configuration service
Spring Cloud implements service discovery through Eureka of Netflix OSS, so that each service can communicate with each other
Server: @EnableEurekaServer; Client: @EnableEurekaClient
1), routing gateway
Implemented by Zuul, providing @EnableZuulProxy to enable routing proxy
2), load balancing
Clients: Ribbon and Feign
Under spring cloud, use Ribbon to directly inject a RestTemplate object
To use Feign, you need to define an annotation, an interface annotated with @FeignClient, and then use @RequestMapping to map the remote Rest service
3), circuit breaker
Mainly to solve when a method fails to call, call the backup solution to replace the failed method to achieve fault tolerance and prevent the cascading error function
@EnableCircuitBreaker enables support, @HystrixCommand's fallbackMethod to specify the fallback scheme
@EnableHystrixDashboard: Enables the console to monitor the operation of the circuit breaker