Fork me on GitHub

SpringBoot配置consul

  1. SpringBoot配置consul:pom

    	<dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-consul-discovery</artifactId>
         </dependency>
    

  2. application.yml

    server:
      port: 80
    spring:
      application:
        name: cloud-consumer-order
      cloud:
        consul:
          # consul注册中心地址
          host: localhost
          port: 8500
          discovery:
            hostname: 127.0.0.1
            service-name: ${spring.application.name}
    

  3. 启动入口文件

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

posted @   壶小旭  阅读(737)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
点击右上角即可分享
微信分享提示