eureka服务端创建好后,现在我们让eureka客户端(也就是服务提供者)注册到eureka上去。

首先加入依赖包:

<!--将微服务provider注册到eureka-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--保证info信息可以显示主管监控和信息配置-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<build>
<finalName>microservicecloud</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<delimiters>
<delimit>$</delimit>
</delimiters>
</configuration>
</plugin>
</plugins>
</build>

yml文件里加入eureka服务端的地址:

spring:
application:
name: microservicecloud #此为微服务的名称,注册到eureka时APPLICATIOIN处显示的就是这个,集群时此名称要一致
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
instance:
instance-id: microservicecloud #些处注册到eureka上时,status处显示的名称,看下图中黑圈处
prefer-ip-address: true #此处为放在eureka中status上时显示ip info:
app.name: microservicecloud-test
company.name: person
build.artifactId: $project.artifactId$
build.version: $project.version$

启动类里面加入@EnableEurekaClient

@SpringBootApplication
@EnableEurekaClient //eureka客户端,启动后自动注册到服务端
public class ServerProvider {
public static void main(String[] args) {
SpringApplication.run(ServerProvider.class, args);
}
}

上图中,我图黑圈那里,显示的为本地localhost,与上面对应。

eureka学习(二)的更多相关文章

  1. SpringCloud学习(二):微服务入门实战项目搭建

    一.开始使用Spring Cloud实战微服务 1.SpringCloud是什么? 云计算的解决方案?不是 SpringCloud是一个在SpringBoot的基础上构建的一个快速构建分布式系统的工具 ...

  2. emberjs学习二(ember-data和localstorage_adapter)

    emberjs学习二(ember-data和localstorage_adapter) 准备工作 首先我们加入ember-data和ember-localstorage-adapter两个依赖项,使用 ...

  3. ReactJS入门学习二

    ReactJS入门学习二 阅读目录 React的背景和基本原理 理解React.render() 什么是JSX? 为什么要使用JSX? JSX的语法 如何在JSX中如何使用事件 如何在JSX中如何使用 ...

  4. TweenMax动画库学习(二)

    目录            TweenMax动画库学习(一)            TweenMax动画库学习(二)            TweenMax动画库学习(三)            Tw ...

  5. Hbase深入学习(二) 安装hbase

    Hbase深入学习(二) 安装hbase This guidedescribes setup of a standalone hbase instance that uses the local fi ...

  6. Struts2框架学习(二) Action

    Struts2框架学习(二) Action Struts2框架中的Action类是一个单独的javabean对象.不像Struts1中还要去继承HttpServlet,耦合度减小了. 1,流程 拦截器 ...

  7. Python学习二:词典基础详解

    作者:NiceCui 本文谢绝转载,如需转载需征得作者本人同意,谢谢. 本文链接:http://www.cnblogs.com/NiceCui/p/7862377.html 邮箱:moyi@moyib ...

  8. Eureka学习例子

    Eureka学习 Spring Cloud下有很多工程: Spring Cloud Config:依靠git仓库实现的中心化配置管理.配置资源可以映射到Spring的不同开发环境中,但是也可以使用在非 ...

  9. Quartz学习--二 Hello Quartz! 和源码分析

    Quartz学习--二  Hello Quartz! 和源码分析 三.  Hello Quartz! 我会跟着 第一章 6.2 的图来 进行同步代码编写 简单入门示例: 创建一个新的java普通工程 ...

随机推荐

  1. 媲美5G的Wifi网速、“备战”资产一键领……揭秘双11小二背后的保障力量

    如今,双11不光是购物狂欢节,更是对技术的一次“大考”,对于阿里巴巴企业内部运营的基础保障技术而言,亦是如此. 回溯双11历史,这背后也经历过“小米加步枪”的阶段:作战室从随处是网线,交换机放地上的“ ...

  2. 前端this相关

    前端this相关: <script> //示例一 function func1() { console.log(this); //this代指window } func1(); //win ...

  3. Python3解leetcode Binary Tree PathsAdd DigitsMove Zeroes

    问题描述: Given an array nums, write a function to move all 0's to the end of it while maintaining the r ...

  4. 接触python的第1天:测试hello world

    在python3.8的平台可以输入了hello world, ide还能当做计算器 >>> print("hello world") hello world &g ...

  5. 左除与右除的区别--MATLAB

    MATLAB 左除与右除的区别 先定义两个矩阵a和矩阵b.如下: /:右除.a/b表示矩阵a乘以矩阵b的逆. \:左除.a\b表示矩阵a的逆乘以b. ./:右除.a./b表示矩阵a中的每个元素除以矩阵 ...

  6. Android中插件开发篇总结和概述

    刚刚终于写完了插件开发的最后一篇文章,下面就来总结一下,关于Android中插件篇从去年的11月份就开始规划了,主要从三个方面去解读Android中插件开发原理.说白了,插件开发的原理就是:动态加载技 ...

  7. R 数据分析

    目录: windows命令行中执行R dataframe 常用函数.变量 1.windows命令行中执行R 前提:已经把R的命令目录加入了系统路径中. 在windows中,命令行执行R可以用以下两种方 ...

  8. JVM调优(二)——基于JVisualVM的可视化监控

    JVM调优(二)--基于JVisualVM的可视化监控 工具路径://java/jdk1.8xxx/bin/JVisuaVM.exe 监控本地的Tomcat 监控远程Tomcat 监控普通的JAVA进 ...

  9. Oracle 11g 的卸载

    Oracle 11g 的卸载 停止 oracle 相关的所有服务. 使用 Oracle 自带的 Universal Installer 卸载工具卸载 Oracle. 删除注册表 HKEY/LOCAL_ ...

  10. JetBrains.dotPeek

    Free .NET Decompiler and Assembly Browser Decompile .NET assemblies to C# dotPeek is a free-of-charg ...