<artifactId>feign-consumer</artifactId>
<packaging>jar</packaging>
<name>feign-consumer</name>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
@EnableDiscoveryClient
@SpringBootApplication
@EnableFeignClients
public class FeignConsumerApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(FeignConsumerApplication.class)
.web(WebApplicationType.SERVLET)
.run(args);
}
}
@FeignClient("eureka-client")
public interface IService {
@GetMapping("/sayHi")
String sayHi();
}
@RestController
public class Controller {
@Autowired
private IService service;
@GetMapping("/sayHi")
public String sayHi() {
return service.sayHi();
}
}
spring.application.name=feign-consumer
server.port=40001
eureka.client.serviceUrl.defaultZone=http://localhost:20000/eureka/