Demo project for Spring Boot
<java.version>11</java.version>
<spring-cloud.version>2020.0.3</spring-cloud.version>
org.springframework.boot
spring-boot-starter-web
org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
org.springframework.boot
spring-boot-starter-test
test
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
配置文件:
server.port=6060
spring.application.name=Provider1
#设置服务注册中心的URL,用于client和server端交流,这里是客户端,寻找主机
eureka.client.service-url.defaultZone=http://euk1.com:8081/eureka/
实现一个Controller:
package com.learn.eurekaprovider1.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MainController {
@GetMapping("/getHi")
public String getHi() {
return “Hello”;
}
}
查看eureka服务器: