zoukankan      html  css  js  c++  java
  • Spring Eureka的使用入门

    Eureka调度服务:

       Gradle依赖包:

    基础框架依赖配置核心代码:

        buildscript {
            repositories {
                mavenCentral()
            }
            dependencies {classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.5.14.RELEASE' }
        }
        
        afterEvaluate {Project  project -> 
            if (project.pluginManager.hasPlugin('java')) {
                configurations.all {
                    resolutionStrategy.eachDependency {DependencyResolveDetails details -> 
                        forceVersion details, 'org.springframework.boot', '1.5.14.RELEASE'
                        forceVersion details, 'org.springframework.cloud:spring-cloud-dependencies', 'Edgware.SR4'
                        forceVersion details, 'org.slf4j', '1.7.21'
                    }
                    exclude module:'slf4j-log4j12'
                    exclude module:'log4j'                
                }
                dependencies {testCompile 'junit:junit:4.12' }            
            }
        }
    
        repositories {
            mavenCentral()
        }

    调度服务bulid.gralde:

    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'
    
    ext {
    	springCloudVersion = 'Edgware.SR4'
    }
    
    dependencies {
        compile 'org.springframework.cloud:spring-cloud-starter-eureka-server'
        compile 'org.springframework:springloaded'
        compile 'org.springframework.boot:spring-boot-devtools'
    }
    
    dependencyManagement {
    	imports {
    		mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    	}
    }
    

    服务启动类:

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
    
    @SpringBootApplication
    @EnableEurekaServer
    public class RegistrationServer {
        
        public static void main(String[] args) {
            SpringApplication.run(RegistrationServer.class, args);
        }
    }

    app.yml配置:

    server:
      port: 8761
    
    eureka: 
      instance:
        hostname: localhost
      client: 
        register-with-eureka: false 
        fetch-registry: false 
        service-url: 
          defaultZone: http://localhost:${server.port}/eureka/
          
    

    启动服务,访问http://127.0.0.1:8761/eureka

    注册中心启动完成;

  • 相关阅读:
    ios---图片缩放
    ios---清除缓存
    ReactNative---组件种类
    Linux 用户和用户组管理
    Linux 文件与目录管理
    linux文件的基本属性
    xshell 快速复制打开之前用过的ssh
    ll 和 ls -l的详解
    laravel rbac的用户 角色 权限的crud
    laravel 中的rbac自己简单的实现
  • 原文地址:https://www.cnblogs.com/liangblog/p/9558678.html
Copyright © 2011-2022 走看看