标签:ice enable 实现 star temp 添加 cti ace cloud
Feign是一个声明式的Web服务客户端,使得编写Web服务客户端变得非常容易,只需要创建一个接口,然后在上面添加注解即可。官网:https://github.com/OpenFeign/feign
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
需要添加开启feign的注解,示例如下:
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@FeignClient(value = "userService")
public interface UserService {
@RequestMapping(value = "/userServiceProvider", method = RequestMethod.GET)
String sayHiFromClientOne(@RequestParam(value = "name") String name);
}
基本类似于Ribbon的配置, application.properties示例如下:
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
server.port=8770
spring.application.name=service-feign
标签:ice enable 实现 star temp 添加 cti ace cloud
原文地址:https://blog.51cto.com/14846948/2510742