Spring Cloud (一):搭建服务注册中心

 1、application.properties # 服务端口server.port=9093spring.application.name=eureka

 1、application.properties

# 服务端口
server.port=9093spring.application.name=eureka-server# 注册中心ip地址 127.0.0.1或者localhost
eureka.instance.hostname=127.0.0.1
# 注册地址
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
# 由于该应用为注册中心,所以设置为false,代表不向注册中心注册自己
eureka.client.register-with-eureka=false
# 因为自己是注册中心,不需要去检索服务信息
eureka.client.fetch-registry=false
# 关闭eureka的自我抱回
eureka.server.enable-self-preservation=falsemanagement.endpoint.health.show-details=always

2、启动项

package cn.com.weking;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication
// 启动服务注册中心
@EnableEurekaServer
public class EurekaServerApplication {public static void main(String[] args) {SpringApplication.run(EurekaServerApplication.class, args);}}

3、pom.xml


4.0.0org.springframework.bootspring-boot-starter-parent2.1.0.RELEASEcn.com.wekingeureka-server0.0.1-SNAPSHOTeureka-serverDemo project for Spring Boot1.8Finchley.RELEASEorg.springframework.cloudspring-cloud-starter-netflix-eureka-serverorg.springframework.bootspring-boot-starter-weborg.springframework.bootspring-boot-starter-actuatororg.springframework.cloudspring-cloud-dependencies${spring-cloud.version}pomimportorg.springframework.bootspring-boot-maven-plugin