根据上篇文章(在Eureka中注册多个服务(根据本地主机端口号区分)),我们已经掌握了Eureka的注入方法。
本次我们需要实现微服务之间的调用,其实是将两个客户端注入Eureka,具体就是换一个注解。
目的:用SClient1中的controller调用SClient0中相应的方法。
项目结构
Pom依赖
在最外层Pom中写入
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>