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

    注册中心启动完成;

  • 相关阅读:
    mysql主从复制的一些东西的整理
    (转载)[我只是认真]聊聊工匠情怀
    Redis运维的一些常用的命令总结
    关于mysql和Apache以及nginx的监控脚本怎么写会比较好的记录
    使用linux的nc来进行文件的传输
    nc检测端口是否正常服务的一个命令
    二维数组去除重复值和array_unique函数
    MySQL的备份的一些策略和方法的总结
    一些容易忘记的小知识点
    关于php多线程的记录
  • 原文地址:https://www.cnblogs.com/liangblog/p/9558678.html
Copyright © 2011-2022 走看看