1、feign进行远程调用
maven jar
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
实现调用服务接口
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
//调用注册的服务
@FeignClient(name="eureka-server")
public interface HelloRemote {
//restful api 调用
@GetMapping("/hello/{name}")
public String hello(@PathVariable("name") String name);
}
启动类加上(basePackages服务接口所在的package)
@EnableFeignClients(basePackages="com.example.demo.remote")
调用服务
import org.springframework.beans.factory.annotation.Autowired;
import org.