Feign学习笔记3-feign不使用eureka
feign不使用eurekamain@EnableFeignClients@SpringBootApplicationpublic class FeignMain {public static void main(String[] args) {SpringApplication.run(FeignMain.class, args);}}server端代码
·
feign不使用eureka
main
@EnableFeignClients
@SpringBootApplication
public class FeignMain {
public static void main(String[] args) {
SpringApplication.run(FeignMain.class, args);
}
}
server端代码
server端依旧是用randomInt
@RequestMapping(value = "/getNum", method = RequestMethod.GET)
public int getRandomInt() {
Random random = new Random();
Integer num = random.nextInt(100);
logger.info("getRandomInt:" + num);
return num;
}
Client端代码
@FeignClient(name = "thisOnlyName", url = "http://localhost:10102")
public interface RestFulService {
/**
* 默认没有参数会使用get方法
*
* @return
*/
@RequestMapping(value = "/getNum")
int getRandomInt();
}
此处通过url直接指定就好了。不需要配置eureka。ribbon也不会生效。单节点个人学习棒棒哒!
更多推荐
已为社区贡献2条内容
所有评论(0)