1.Eureka

作者: 面具猴 | 来源:发表于2019-05-28 08:57 被阅读0次

    EurekaServer:

    1.依赖

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    </dependency>
    

    2.配置

    #basic
    server.port=8001
    #eureka
    eureka.client.register-with-eureka=false
    eureka.client.fetch-registry=false
    eureka.client.service-url.defaultZone=http://127.0.0.1:${server.port}/eureka
    

    3.启动

    @SpringBootApplication
    @EnableEurekaServer
    public class EurekaServer {
        public static void main(String[] args) {
            SpringApplication.run(EurekaServer.class);
        }
    }
    

    4.测试

    http://127.0.0.1:8001/
    

    EurekaClient:

    1.依赖

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    

    2.配置

    #eureka
    eureka.client.service-url.defaultZone=http://127.0.0.1:8001/eureka
    eureka.instance.prefer-ip-address=true
    

    3.启动

    @SpringBootApplication
    @EnableEurekaClient
    public class ArticleApplication {
        public static void main(String[] args) {
            SpringApplication.run(ArticleApplication.class, args);
        }
    }
    

    4.测试
    http://127.0.0.1:8001/ 中看到Application下有此项目

    相关文章

      网友评论

          本文标题:1.Eureka

          本文链接:https://www.haomeiwen.com/subject/dahjnqtx.html