1.pom.xml
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency>
2.application.properties
# 設置服務端口
server.port=8881
# 設置服務名
spring.application.name=hello-service
# 設置注冊中心地址
eureka.client.service-url.defaultZone=http://localhost:7777/eureka
3.啟動服務提供者
package org.huqi.springcloudclient; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; @SpringBootApplication @EnableEurekaClient public class SpringcloudclientApplication { public static void main(String[] args) { SpringApplication.run(SpringcloudclientApplication.class, args); } }