zoukankan      html  css  js  c++  java
  • (七)SpringCloud学习系列-Eureka服务注册与发现(2)

    转载:https://www.cnblogs.com/XiangHuiBlog/p/12089755.html

    构建 microservicecloud-eureka-7001 eureka服务注册中心Module

    1.新建microservicecloud-eureka-7001

    2.pom

    复制代码
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
     
      <parent>
       <groupId>com.atguigu.springcloud</groupId>
       <artifactId>microservicecloud</artifactId>
       <version>0.0.1-SNAPSHOT</version>
      </parent>
     
      <artifactId>microservicecloud-eureka-7001</artifactId>
     
      <dependencies>
       <!--eureka-server服务端 -->
       <dependency>
         <groupId>org.springframework.cloud</groupId>
         <artifactId>spring-cloud-starter-eureka-server</artifactId>
       </dependency>
       <!-- 修改后立即生效,热部署 -->
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>springloaded</artifactId>
       </dependency>
       <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-devtools</artifactId>
       </dependency>
      </dependencies>
     
    </project>
    复制代码

    3.yml

    复制代码
     
    server: 
      port: 7001
     
    eureka:
      instance:
        hostname: localhost #eureka服务端的实例名称
      client:
        register-with-eureka: false #false表示不向注册中心注册自己。
        fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务
        service-url:
          defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/        #设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个地址。
     
    复制代码

    4.EurekaServer7001_App主启动类

    复制代码
    package com.atguigu.springcloud;
     
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
     
    @SpringBootApplication
    @EnableEurekaServer//EurekaServer服务器端启动类,接受其它微服务注册进来
    public class EurekaServer7001_App
    {
      public static void main(String[] args)
      {
       SpringApplication.run(EurekaServer7001_App.class, args);
      }
    }
     
     
    复制代码

    5.测试

    先要启动EurekaServer

    http://localhost:7001/

  • 相关阅读:
    全文搜索 Contains 与like 的区别
    Easyui _treegrid 动态加载子节点
    十五、ES开启SSL访问
    十二、ES分词器
    十一、ES监控
    十六、源码部署EFK之快乐没有了
    十四、ES开启密码认证
    十三、ES备份恢复
    十七、优化ES
    正则表达式
  • 原文地址:https://www.cnblogs.com/cjh184/p/12787144.html
Copyright © 2011-2022 走看看