Spring Cloud (一):搭建服务注册中心
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.0 org.springframework.boot spring-boot-starter-parent 2.1.0.RELEASE cn.com.weking eureka-server 0.0.1-SNAPSHOT eureka-server Demo project for Spring Boot 1.8 Finchley.RELEASE org.springframework.cloud spring-cloud-starter-netflix-eureka-server org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-actuator org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} pom import org.springframework.boot spring-boot-maven-plugin
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
