博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring cloud之eureka搭建
阅读量:4171 次
发布时间:2019-05-26

本文共 2404 字,大约阅读时间需要 8 分钟。

这篇文章为大家搭建一个eureka项目,主要展示其服务发现的功能:

首先添加pom依赖,如果使用idea创建maven项目时可以直接选择相关依赖,这里使用eclipse手把手搭建:

4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.1.RELEASE
com.zsy.cloud
cloud-eureka
0.0.1-SNAPSHOT
jar
zsy-eureka
1.8
Greenwich.M3
org.springframework.cloud
spring-cloud-starter-netflix-eureka-server
org.springframework.boot
spring-boot-starter-test
test
org.springframework.cloud
spring-cloud-dependencies
${spring-cloud.version}
pom
import
org.springframework.boot
spring-boot-maven-plugin
spring-milestones
Spring Milestones
https://repo.spring.io/milestone
false

 

yml文件:

server:  port: 8081  #服务端口###服务名称(服务注册到eureka名称,如果需要注册自己,必须声明服务名称)spring:  application:    name: eureka-servereureka:  instance:    ###注册到eurekaip地址    hostname: 127.0.0.1  client:    serviceUrl:      # 注册中心服务接口,别的服务需要注册时使用这个接口即可(最好一个斜杠后面的服务名称必须是eureka)      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka    ###因为自己是注册中心,不需要自己注册自己    register-with-eureka: false    ###因为自己是注册中心,不需要检索服务    fetch-registry: false  server:    # 测试时关闭自我保护机制,保证不可用服务及时踢出    enable-self-preservation: false    eviction-interval-timer-in-ms: 2000

启动类:

package com.zsy.cloud.eureka;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication@EnableEurekaServerpublic class EurekaServerApp {	public static void main(String[] args) {		SpringApplication.run(EurekaServerApp.class, args);	}}

 

eureka管理页面:

 

页面显示没有服务注册,下一章写个client进行注册。

转载地址:http://tpbai.baihongyu.com/

你可能感兴趣的文章
How to Reset or Change Microsoft Office 2007 Product License Key or Volume License Key (VLK)
查看>>
使用java concurrent调用xmlp api生成pdf
查看>>
Oracle日期计算之INTERVAL
查看>>
Oracle PL/SQL之EXCEPTION
查看>>
Oracle PL/SQL之EXCEPTION -- WHEN OTHERS THEN
查看>>
Oracle PL/SQL之VARCHAR2 QUALIFIER
查看>>
Oracle PL/SQL之处理index不连续的table类型变量
查看>>
Oracle PL/SQL之嵌套表(Nested Table)
查看>>
Oracle PL/SQL之令人不解的提示(nls_date_format)
查看>>
Oracle PL/SQL之GROUP BY ROLLUP
查看>>
Oracle PL/SQL之GROUP BY CUBE
查看>>
蓝桥杯2018省赛 - A3 乘积尾零
查看>>
蓝桥杯2018省赛 - A4 第几个幸运数
查看>>
命令窗口中javac(即javac.exe)不可用的原因
查看>>
如何完全卸载VS2010
查看>>
【算法概论】分治算法:计算数组中的逆序对
查看>>
【算法概论】分治算法:查找中位数
查看>>
【算法概论】分治算法:k路归并
查看>>
Python debug 一
查看>>
向量vector的初始化
查看>>