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的更多相关文章

  1. Spring Cloud Security&Eureka安全认证(Greenwich版本)

    Spring Cloud Security&Eureka安全认证(Greenwich版本) 一·安全 Spring Cloud支持多种安全认证方式,比如OAuth等.而默认是可以直接添加spr ...

  2. Spring Cloud Greenwich 正式发布,Hystrix 即将寿终正寝。。

    Spring Cloud Greenwich 正式版在 01/23/2019 这天正式发布了,下面我们来看下有哪些更新内容. 生命周期终止提醒 Spring Cloud Edgware Edgware ...

  3. Spring Cloud Greenwich.SR4 发布了,跟不上了……

    前几天 Spring Cloud Greenwich.SR4 发布了: https://spring.io/blog/2019/11/19/spring-cloud-greenwich-sr4-rel ...

  4. Spring Cloud Greenwich 新特性和F升级分享

    2019.01.23 期待已久的Spring Cloud Greenwich 发布了release版本,作为我们团队也第一时间把RC版本替换为release,以下为总结,希望对你使用Spring Cl ...

  5. spring cloud之eureka简介

    最近线上的接口出了一些问题,有一些可能不是代码的问题,但是由于是测试和其他方面的同事爆出来的,所以感觉对接口的监控应该提上日程. 经过搜索发现,spring cloud的eureka就是专门做这方面工 ...

  6. Spring cloud系列教程第十篇- Spring cloud整合Eureka总结篇

    Spring cloud系列教程第十篇- Spring cloud整合Eureka总结篇 本文主要内容: 1:spring cloud整合Eureka总结 本文是由凯哥(凯哥Java:kagejava ...

  7. Spring Cloud与Eureka

    Spring Cloud与Eureka 一.使用SpringCloud注册中心Eureka 1.1 Eureka和Zookeeper对比 1.1.1 Zookeeper保证CP 1.1.2 Eurek ...

  8. 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 ...

  9. 1. Spring Cloud Greenwich SR2 概览

    Spring Cloud provides tools for developers to quickly build some of the common patterns in distribut ...

随机推荐

  1. 【Python基础】lpthw - Exercise 38 列表的操作

    1.列表和字符串操作的混合练习 ten_things = "apples oranges crows telephone light sugar" print("Wait ...

  2. 关于php得到参数数据

    通过GET得到参数数据 $_SERVER['QUERY_STRING'] 获取?后面的值 $_SERVER['SCRIPT_NAME'] 获取当前脚本的路径 具体参数通过_GET['参数']获得 fi ...

  3. WinAPI 字符及字符串函数(15): CharNext、CharPrev

    unit Unit1; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, For ...

  4. jmeter 之调试

    目前知道的调试方法有两种:debug sample .http mirror server debug sample  debug sample 的用户界面如下: 如果选择ture则表示打印对应的数据 ...

  5. JDBC 查询

    //查询""SMITH"的empno import java.sql.Connection; import java.sql.DriverManager; import ...

  6. springboot热部署配置

    1.pom添加spring-boot-devtools依赖和配置编译插件 <dependency> <groupId>org.springframework.boot</ ...

  7. Spark 学习笔记

    Spark的前世今生   基础语法详解   3.条件控制与循环   4.函数入门   5.函数入门之默认参数   6.函数入门之边长参数   7.函数入门之过程lazy值和异常   8.数组操作之Ar ...

  8. webapi发布到windows 2012的iis8里 出错

    HTTP 错误 403.14 - Forbidden Web 服务器被配置为不列出此目录的内容. 选一个.net版本一致的应用程序池 即可

  9. Python 进阶 异步async/await

    一,前言 本文将会讲述Python 3.5之后出现的async/await的使用方法,我从上看到一篇不错的博客,自己对其进行了梳理.该文章原地址https://www.cnblogs.com/dhcn ...

  10. python值json与pickle模块

    #json 是用来序列化对象的 # 只有2个方法,序列化与反序列化 # 但是不能序列化类 与 函数 import json dict={"key1":[1,2,3,4,5]} f ...