这是一个简单的springcloud工程,基于eureka+feign+hystrix
github地址:https://github.com/weiess/springCloud.git
简单的解释下:
eureka是服务注册与发现的
feign是用来调用服务的,其实还有restTemplate,原理和feign一样,都是通过httpclient去掉用服务
hystrix断路器其实就是帮助处理异常的,意思是,调用服务接口的时候,服务挂了,可以用断路器解决
因为cloud项目比较大,在实际项目中会有很多子项目,所以笔者这边也用了父子maven搭建了一个简单的springcloud项目,先看下结构:
com.yzl.cloud是一个父工程,其主要作用就是管理jar,留下pom.xml
即可,但是pom中要加入<modules>标签管理子项目,其他的子项目都在父工程里,pom中要加入父项目坐标也就是 <parent>标签,如果大家对于父子工程不太懂的可以自行百度,笔者这里不多说。
给大家看下springcloud相关依赖:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yzl.cloud</groupId>
<artifactId>com.yzl.cloud</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>com.yzl.Eureka</module>
<module>com.yzl.Feign</module>
<module>com.yzl.Client</module>
</modules>
<name>com.yzl.cloud</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.0.4.RELEASE</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.1.2.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
<version>2.1.7.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
springcloud本质还是基于springboot,所以spring-boot-starter-parent我们必须要引用。
Eureka
我们先搭建服务注册中心,pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yzl.cloud</groupId>
<artifactId>com.yzl.cloud</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.yzl.Eureka</groupId>
<artifactId>com.yzl.Eureka</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>com.yzl.Eureka Maven Webapp</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>com.yzl.Eureka</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
搭建Eureka主要就一个jar:spring-cloud-starter-netflix-eureka-server
我们只需要在yml配置几个参数:
server:
port: 8080
spring:
application:
name: eurka-server
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
eureka-server-u-r-l-context: http://${eureka.instance.hostname}:${server.port}/eureka/
这里注意spring. application.name: eurka-server这个参数一定要加,表示自己注册的服务名字
由于引入的cloud jar版本不同,里面的参数可能稍微不一样,所以大家配置yml的时候最好根据快捷提示来配置
启动类加一个注解@@EnableEurekaServer
package com;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
@EnableEurekaServer 表示自动开启Eureka服务端,也表示它是服务器
这样一个简单的服务注册中心就搭建完了
我们根据端口号启动下:
以上页面就表示Eureka搭建完成
Client
客户端表示提供服务,概念上就是所谓的生产者,它让自己的接口注册到Eureka上
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yzl.cloud</groupId>
<artifactId>com.yzl.cloud</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.yzl.Eureka</groupId>
<artifactId>com.yzl.Eureka</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>com.yzl.Eureka Maven Webapp</name>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>com.yzl.Eureka</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
没错,最简单的生产者搭建就是一个spring-cloud-starter-netflix-eureka-client
当然实际项目中,一个生产者就是一个模块,里面包括相应的业务以及其他功能需求;
生产者提供接口的时候只要在接口中加入@EnableEurekaClient注解
package com;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaClient
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
@EnableEurekaClient 表示自动开启Eureka客户端,也表示它是生产者
yml:
server:
port: 8081
eureka:
client:
service-url:
defaultZone: http://localhost:8080/eureka/
spring:
application:
name: eurka-client
这里是最简单的生产者搭建,所以许多配置笔者也没加,实际中可以根据自己需求加入相应配置,注意eureka:
client:service-url这个属性是必须的,这表示生产者要找的服务注册中心地址。
暴露的接口,其实就是controller中的类:
package com.yzl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/")
public class HelloController {
@GetMapping("/getData")
public String getData(String name){
return "hello get"+name;
}
@PostMapping("/postData")
public String postData(String name){
return "hello post"+name;
}
}
controller和servcie其实和普通的项目一样,没有其他操作,在启动类加入相关注解,就会自动把controller的接口暴露在Eureka上;
我们启动项目,可以看到Eureka上多了一个注册服务:
这个红字表示:
这是因为Eureka进入了自我保护机制,默认情况下,如果EurekaServer在一定时间内没有接收到某个微服务实例的心跳时,EurekaServer将会注销该实例(默认90s)。但是当网络发生故障时,微服务与EurekaServer之间无法通信,这样就会很危险了,因为微服务本身是很健康的,此时就不应该注销这个微服务,而Eureka通过自我保护机制来预防这种情况,当网络健康后,该EurekaServer节点就会自动退出自我保护模式;
大家可以无视这段红字或者可以关闭自我保护机制:
eureka.server.enable-self-preservation#设置为false,关闭自我保护
我们主要看红框框的那一块,表示有服务注册到Eureka里,这里的Application表一个注册服务,它的名字也就是yml配置的:
spring:
application:
name: eurka-client
注册到Eureka会默认大写。
这样一个简单的生产者就搭建完毕,它会将自己提供的接口暴露给Eureka,然后消费者通过方法去Eureka寻找相关接口,然后调用,完全解决耦合问题,这样各个模块自己独立开发,需要相关接口的时候,就去Eureka调用,而且还不影响生产者本身使用。
Feign+hystrix
Feign是Netflix开发的声明式、模板化的HTTP客户端,其实就是相当于httpClient。当然它的功能更加强大,
Spring Cloud Feign是基于Netflix feign实现,整合了Spring Cloud Ribbon和Spring Cloud Hystrix,不仅可以负载均衡(如果相同的生产者有N个,比如有127.0.0.1,127.0.0.2两个相同的生产者,他的Application名字要相同,Feign会用相应的算法去请求生产者,调用其中一个,达到负载均衡的目的),而且可以提供断路机制(简单的说就是处理服务异常,当然断路器功能比这个更加丰富)
先给大家看下消费者的项目:
项目结构很简单,笔者也没有分层。这里的yml也贴出来了:
server:
port: 8082
spring:
application:
name: eurka-feign
eureka:
client:
service-url:
defaultZone: http://localhost:8080/eureka/
feign:
hystrix:
enabled: true
feign: hystrix: enabled: true 表示开启断路器
给大家看下消费者的pom:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yzl.cloud</groupId>
<artifactId>com.yzl.cloud</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.yzl.Feign</groupId>
<artifactId>com.yzl.Feign</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>com.yzl.Feign Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
</project>
启动类:
package com;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableFeignClients
@EnableHystrix
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
@EnableHystrix 表示开启断路器
@EnableFeignClients 表示开启Feign
我们用Feign调用Eureka接口的时候我们只需要声明一个接口:
package com.yzl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(value = "EURKA-CLIENT",fallback = HelloHystrix.class)
public interface HelloService {
@RequestMapping(value = "/getData",method = RequestMethod.GET)
String getHello(@RequestParam(value = "name") String name);
@RequestMapping(value = "/postData",method = RequestMethod.POST)
String postHello(@RequestParam(value = "name") String name);
}
这里要注意几点:
1.@FeignClient(value = "EURKA-CLIENT",fallback = HelloHystrix.class)这里@FeignClient里面的参数value表示要调用的Eureka地址(也就是Eureka上的Application下面的名字),一定要相同;后面的fallback表示异常处理,就是如果调用生产者者接口,但是生产者挂了,或者超时等等情况,可以用HelloHystrix这个类来处理,这个类笔者后面说。
2.@RequestParam(value = "name") 这个参数一定要加,笔者没加就出现异常 ,类似这样的异常(当然如果你加了fallback,异常处理机制就不一样了);
feign.FeignException: status 405 reading HelloService#getHello(String); content:
{"timestamp":"2019-09-28T12:13:55.971+0000","status":405,"error":"Method Not Allowed","message":"Request method 'POST' not supported","path":"/getData"}
at feign.FeignException.errorStatus(FeignException.java:62) ~[feign-core-9.5.1.jar:na]
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91) ~[feign-core-9.5.1.jar:na]
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138) ~[feign-core-9.5.1.jar:na]
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76) ~[feign-core-9.5.1.jar:na]
at feign.hystrix.HystrixInvocationHandler$1.run(HystrixInvocationHandler.java:108) ~[feign-hystrix-9.5.1.jar:na]
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:302) ~[hystrix-core-1.5.12.jar:1.5.12]
at com.netflix.hystrix.HystrixCommand$2.call(HystrixCommand.java:298) ~[hystrix-core-1.5.12.jar:1.5.12]
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:46) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8]
at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:51) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDefer.call(OnSubscribeDefer.java:35) ~[rxjava-1.3.8.jar:1.3.8]
at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:41) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeDoOnEach.call(OnSubscribeDoOnEach.java:30) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:48) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30) ~[rxjava-1.3.8.jar:1.3.8]
at rx.Observable.unsafeSubscribe(Observable.java:10327) ~[rxjava-1.3.8.jar:1.3.8]
at rx.internal.operators.OperatorSubscribeOn$SubscribeOnSubscriber.call(OperatorSubscribeOn.java:100) ~[rxjava-1.3.8.jar:1.3.8]
at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:56) ~[hystrix-core-1.5.12.jar:1.5.12]
at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction$1.call(HystrixContexSchedulerAction.java:47) ~[hystrix-core-1.5.12.jar:1.5.12]
at com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction.call(HystrixContexSchedulerAction.java:69) ~[hystrix-core-1.5.12.jar:1.5.12]
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) ~[rxjava-1.3.8.jar:1.3.8]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_161]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_161]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_161]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_161]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161]
接着我们看下HelloHystrix,也就是断路器处理:
package com.yzl;
import org.springframework.stereotype.Component;
@Component
public class HelloHystrix implements HelloService {
@Override
public String getHello(String name) {
return "get ex";
}
@Override
public String postHello(String name) {
return "post ex";
}
}
这边没什么好说的就是实现了生产者的接口,重写他的方法,返回你需要的返回值,让你判断。这里笔者就简单的写了个返回值,但是@Component这个注解是一定要加的,他要注入到spring的容器中去。
controller调用和平时没太多区别:
package com.yzl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/")
public class HelloController {
@Autowired
private HelloService service;
@GetMapping("/hello")
public String hello(){
return "hello";
}
@GetMapping("/getData")
public String getData(@RequestParam("name") String name){
return service.getHello(name);
}
@GetMapping("/postData")
public String postData(@RequestParam("name") String name){
return service.postHello(name);
}
}
就是调用生产者的接口即可。
我们依次开启Eureka——client——Feign,观察Eureka的情况:
随便请求一个路径,如果成功,返回json到页面
这里说一下,8080是Eureka服务端,8081是生产者,8082是消费者
如果失败(我们可以关闭8081),它会根据Hystrix处理返回HelloHystrix的json数据
现在我们可以看下Eureka服务器情况:
就一个消费者还是在线的。
好了,这是一个最简单的springcloud搭建,但could的功能远远不止这些,相关代码已上传git
github地址:https://github.com/weiess/springCloud.git
谢谢!