Spring cloud Greenwich Eureka
1、父工程POM文件中:
<dependencyManagement>
<dependencies>
<!--spring cloud-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement> <repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
这里需要注意的是,一般的依赖都可以从Maven Repository中导入,但是spring cloud dependencies现在在里面是找不到的了。
所以,在pom文件内,自己指定了远程仓库(通过代码中repositroy配置),远程仓库地址:https://repo.spring.io/milestone/,在这个里面你是可以找到最新的springcloud的各个依赖的,这里截取部分:

可以看到,当前最新的版本是Greewich.SR1,今年1月22日更新的。我选择的是之前一点的版本也是现在spring官网的最新推荐版本Greewich.RELEASE,各取所需吧。
2、导入依赖之后,新建子模块Eureka-server,pom文件:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--Netflix Eureka服务端-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
3、配置文件application.yml:
spring:
application:
name: eureka-server
# 自己设置一个端口号,方便之后访问
server:
port: 6543
# Eureka-server的简单配置
eureka:
instance:
hostname: 127.0.0.1
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
4、新建启动类Application并配置开启服务:
@EnableEurekaServer
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
5、启动服务查看服务:

Eureka的服务端配置完成。
6、新建一个微服务Test:
pom文件
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
application.yml
spring:
application:
name: test
server:
port: 8002
eureka:
instance:
hostname: 127.0.0.1
client:
# 配置为true,注册进服务中心(Eureka server)
register-with-eureka: true
# 配置Eureka server的服务URL
service-url:
defaultZone: http://${eureka.instance.hostname}:7001/eureka/
Application:
@EnableEurekaClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
7、开启Test微服务,刷新Eureka Server的页面,就会发现有一个微服务已经注册进了服务中心了。
个人能力有限,欢迎交流学习,帮助指明错误,希望转载注明出处,谢谢。
Spring cloud Greenwich Eureka的更多相关文章
- Spring Cloud Security&Eureka安全认证(Greenwich版本)
Spring Cloud Security&Eureka安全认证(Greenwich版本) 一·安全 Spring Cloud支持多种安全认证方式,比如OAuth等.而默认是可以直接添加spr ...
- Spring Cloud Greenwich 正式发布,Hystrix 即将寿终正寝。。
Spring Cloud Greenwich 正式版在 01/23/2019 这天正式发布了,下面我们来看下有哪些更新内容. 生命周期终止提醒 Spring Cloud Edgware Edgware ...
- Spring Cloud Greenwich.SR4 发布了,跟不上了……
前几天 Spring Cloud Greenwich.SR4 发布了: https://spring.io/blog/2019/11/19/spring-cloud-greenwich-sr4-rel ...
- Spring Cloud Greenwich 新特性和F升级分享
2019.01.23 期待已久的Spring Cloud Greenwich 发布了release版本,作为我们团队也第一时间把RC版本替换为release,以下为总结,希望对你使用Spring Cl ...
- spring cloud之eureka简介
最近线上的接口出了一些问题,有一些可能不是代码的问题,但是由于是测试和其他方面的同事爆出来的,所以感觉对接口的监控应该提上日程. 经过搜索发现,spring cloud的eureka就是专门做这方面工 ...
- Spring cloud系列教程第十篇- Spring cloud整合Eureka总结篇
Spring cloud系列教程第十篇- Spring cloud整合Eureka总结篇 本文主要内容: 1:spring cloud整合Eureka总结 本文是由凯哥(凯哥Java:kagejava ...
- Spring Cloud与Eureka
Spring Cloud与Eureka 一.使用SpringCloud注册中心Eureka 1.1 Eureka和Zookeeper对比 1.1.1 Zookeeper保证CP 1.1.2 Eurek ...
- Spring Boot,Spring Cloud,Eureka,Actuator,Spring Boot Admin,Stream,Hystrix
Spring Boot,Spring Cloud,Eureka,Actuator,Spring Boot Admin,Stream,Hystrix 一.Spring Cloud 之 Eureka. 1 ...
- 1. Spring Cloud Greenwich SR2 概览
Spring Cloud provides tools for developers to quickly build some of the common patterns in distribut ...
随机推荐
- 海思编译链编译出现__aeabi_unwind_cpp_pr1重定义怎么回事
1.用arm-hisiv100nptl-linux-gcc编译代码,结果发现报错,__aeabi_unwind_cpp_pr1重定义,在librt.a先定义,使用的海思芯片是hi3520d. 2.本来 ...
- 解决spring 用@Value注入配置时候出现中文乱码问题
只要是乱码,很明显需要指定编码格式,为utf-8 <!-- 注解使用properties --> <bean id="configProperties" clas ...
- Python全栈-JavaScript】jQuery工具
jQuery工具 一.jQuery.browser.version 显示当前 IE 浏览器版本号. if ( $.browser.msie ) alert( $.browser.version ); ...
- Luogu4113 [HEOI2012]采花
题目大意:给定一个长度为$n$的序列$a_i$,$m$次询问,每次询问$[l,r]$,求在区间内有多少个数出现了至少2次. 数据范围:$1\leq l\leq r\leq n\leq 2*10^6,1 ...
- Tea for Mac(mac笔记软件)中文版
为大家分享一款好用且免费的mac笔记软件,Tea for Mac提供了实时渲染的Markdown,功能全面,支持各种快捷键,使用tea mac版时,在段首打@即可快速插入图片.标题.列表等元素,非常便 ...
- Mysql+keepalived双主
搭建环境说明: master1:192.168.175.210 主 master2:192.168.175.211 备 keepalived的vip: 192.168.175.11(注意这是虚拟IP, ...
- elasticsearch 之编译过程
https://github.com/elastic/elasticsearch/blob/master/CONTRIBUTING.md 不同的版本需要指定JDK 可以下载openJDK版本到服务器上 ...
- 关于$ORACLE_HOME/bin/oracle文件属性
OS:AIX 7.1DB:12.1.0.2.0 RAC oracle@DB01:/home/oracle>sqlplus / as sysdba SQL*Plus: Release 12.1.0 ...
- python数组相关知识
1.np中的reshape函数,可以把矩阵重新划分成m行n列. arange(n)可以把 [0,n-1]装入数组中,一定要注意的是img.reshape()并不会改变原来的数组,所以需要另外新建一个数 ...
- Python--Virtualenv简明教程(转载https://www.jianshu.com/p/08c657bd34f1)
virtualenv is a tool to create isolated Python environments. virtualenv通过创建独立Python开发环境的工具, 来解决依赖.版本 ...