server.port=8082 #指定服务名称为Server-Provider,后续服务消费者要获取上面TestController中接口的时候会用到这个服务名; spring.application.name=Service-Provider eureka.client.fetch-registry=true eureka.client.register-with-eureka=true eureka.client.serviceUrl.defaultZone=http://peer1:8080/eureka/,http://peer2:8081/eureka/
@SpringBootApplication @EnableDiscoveryClient public class ClientApplication { public static void main(String[] args) { SpringApplication.run(ClientApplication.class, args); } }
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Edgware.SR3</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> </dependencies>