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); } }