• Spring Cloud之Eureka环境搭建


    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>
      <groupId>com.toov5</groupId>
      <artifactId>SpringCloud-eureka-server</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <parent>
    		<groupId>org.springframework.boot</groupId>
    		<artifactId>spring-boot-starter-parent</artifactId>
    		<version>2.0.1.RELEASE</version>
    	</parent>
    	<!-- 管理依赖 -->
    	<dependencyManagement>
    		<dependencies>
    			<dependency>
    				<groupId>org.springframework.cloud</groupId>
    				<artifactId>spring-cloud-dependencies</artifactId>
    				<version>Finchley.M7</version>
    				<type>pom</type>
    				<scope>import</scope>
    			</dependency>
    		</dependencies>
    	</dependencyManagement>
    	<dependencies>
    		<!--SpringCloud eureka-server -->
    		<dependency>
    			<groupId>org.springframework.cloud</groupId>
    			<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    		</dependency>
    	</dependencies> 
    	<!-- 注意: 这里必须要添加, 否者各种依赖有问题 -->
    	<repositories>
    		<repository>
    			<id>spring-milestones</id>
    			<name>Spring Milestones</name>
    			<url>https://repo.spring.io/libs-milestone</url>
    			<snapshots>
    				<enabled>false</enabled>
    			</snapshots>
    		</repository>
    	</repositories>
      
    </project> 

    yml:

    ###eureka 服务端口号
    server:
      port: 8100
    ###服务注册名称
    eureka:
      instance:
      ##注册中心ip地址
        hostname: 127.0.0.1
    ###客户端调用地址
      client:
        serviceUrl:
          defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
    ###因为该应用为注册中心,不会注册自己 (集群设为true)
        register-with-eureka: false
    ###因为自己为注册中心 ,不会去在该应用中的检测服务  
        fetch-registry: false
    

     Eureka:

    package com.toov5;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @EnableEurekaServer   //开启注册中心
    @SpringBootApplication 
    public class AppEureka {
      
         public static void main(String[] args) {
               SpringApplication.run(AppEureka.class, args);
        }
        
    }

    目录结构:

     启动后的访问:

  • 相关阅读:
    李宏毅 Keras手写数字集识别(优化篇)
    李宏毅 Keras2.0演示
    李宏毅 线性回归预测PM2.5
    李宏毅 Gradient Descent Demo 代码讲解
    Pandas导入导出&pickle文件模块
    python(29)Tinker+BeautifulSoup+Request抓取美女壁纸
    golang(11) 反射用法详解
    golang(10)interface应用和复习
    golang(09) golang 接口内部实现
    golang(08)接口介绍
  • 原文地址:https://www.cnblogs.com/toov5/p/9947993.html
Copyright © 2020-2023  润新知