SpringBoot:Eureka搭建注册中心

清疚 2022-11-21 01:25 305阅读 0赞

搭建很简单,就以下三个文件:

  • pom




    org.springframework.cloud
    spring-cloud-dependencies
    Greenwich.SR1
    pom
    import



    org.springframework.boot
    spring-boot-starter-parent
    2.1.5.RELEASE
    pom
    import


  • 配置文件

    eureka:
    client:

    1. fetch-registry: false
    2. register-with-eureka: false

    instance:

    1. hostname: localhost

    server:
    port: 20000
    spring:
    application:

    1. name: eureka-server
  • Application

    @SpringBootApplication
    @EnableEurekaServer
    public class EurekaServerApplication {

    1. public static void main(String[] args) {
    2. new SpringApplicationBuilder(EurekaServerApplication.class)
    3. .web(WebApplicationType.SERVLET)
    4. .run(args);
    5. }

    }

然后启动项目,访问http://localhost:20000/,能看到以下页面就表示启动成功了!
在这里插入图片描述

发表评论

表情:
评论列表 (有 0 条评论,305人围观)

还没有评论,来说两句吧...

相关阅读