zoukankan      html  css  js  c++  java
  • springcloud搭建eureka服务

    springcloud搭建eureka服务

    1、创建一个springboot的pom工程作为父工程控制版本

    案例创建的工程名为:springcloue_parent_02

    修改pom文件

    • 修改工程类型为pom
    <packaging>pom</packaging>
    
    • 导入依赖
    <!--Springcloud的依赖库文件版本的锁定-->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    

    2、创建子工程搭建eureka服务

    案例子工程名为:eureka

    2.1、修改pom文件

    • 继承父工程,eg:
    <parent>
        <groupId>com.yl</groupId>
        <artifactId>springcloue_parent_02</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    
    • 导入依赖
     <!--配置eureka依赖库组件-->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>
    

    2.3、配置全局文件

    spring:
      application:
        name: eureka
    server:
      port: 7001
      #eureka的基本信息
    eureka:
      instance:
        hostname: eureka.com
      client:
        service-url:
          #也可以写成 http://${eureka.instance.hostname}:${server.port}/eureka/
          #如果hostname不是localhost需要在windows配置ip映射
          defaultZone:  http://127.0.0.1:7001/eureka/
        #本身就是注册中心,不需要注册
        register-with-eureka: false
        #本身就是注册中心,不需要获取注册信息
        fetch-registry: false
    

    2.4、启动类添加eureka服务端注解

    package com.yl.eureka;
    
    import org.springframework.boot.Banner;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @SpringBootApplication
    @EnableEurekaServer
    public class EurekaApplication {
    
        public static void main(String[] args) {
    //        SpringApplication.run(EurekaApplication.class, args);
            SpringApplication springApplication=new SpringApplication(EurekaApplication.class);
            springApplication.setBannerMode(Banner.Mode.OFF);
            springApplication.run(args);
        }
    
    }
    

    浏览器访问eureka服务:http://localhost:7001

    记得快乐
  • 相关阅读:
    postgresql大批量数据导入方法
    Odoo 的库存管理与OpenERP之前的版本有了很大的不同,解读Odoo新的WMS模块中的新特性
    一招解决OpenERP8.0安装旧版模块报错
    window下python 扩展库安装 使用第三方镜像源
    OpenERP 安装在Windows server上时间显示不对的解决办法
    深入理解OpenERP的工作流(Workflow)
    Need to add a caption to a jpg, python can't find the image
    OE中admin的内置帐号
    [Linux] Git: 基本使用
    ubuntu下实现openerp 7使用nginx反正代理及绑定域名
  • 原文地址:https://www.cnblogs.com/Y-wee/p/14129138.html
Copyright © 2011-2022 走看看