spring cloud 建立一個服務提供者 (eureka client)

當client向server註冊時,它會提供一些元數據,例如主機和端口,URL,主頁等。Eureka server 從每一個client實例接收心跳消息。 若是心跳超時,則一般將該實例從註冊server中刪除。spring

經過註解@EnableEurekaClient 代表本身是一個eurekaclient.app

@SpringBootApplication
@EnableEurekaClient
@RestController
public class ServiceHiApplication {

   public static void main(String[] args) {
      SpringApplication.run(ServiceHiApplication.class, args);
   }

   @Value("${server.port}")
   String port;
   @RequestMapping("/hi")
   public String home(@RequestParam String name) {
      return "hi "+name+",i am from port:" +port;
   }
}
#鏈接註冊中心地址
eureka.client.serviceUrl.defaultZone = http://localhost:8761/eureka/
server.port=8762
spring.application.name=service-hi
相關文章
相關標籤/搜索