栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

微服务简单上手

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

微服务简单上手

sd1:创建一个像这样的项目,下面有很多子模块,子模块需要继承父模块的pom文件

 2:引入依赖:

        
            org.springframework.boot
            spring-boot-starter-web
        


        
        
            org.springframework.cloud
            spring-cloud-starter-consul-discovery
        


        
        
            org.springframework.boot
            spring-boot-starter-actuator
        



        
        
            org.springframework.cloud
            spring-cloud-starter-openfeign
        

 注意:我这里是根据consul为注册中心依赖。启动consul

3:然后我们配置好application.properties文件

server.port=8087
# 指定服务名称(不区分大小写)
spring.application.name=product


# consul server 服务注册地址
spring.cloud.consul.host=localhost
spring.cloud.consul.port=8500
# 执行注册当前服务的服务名称 默认: ${spring.application.name}
spring.cloud.consul.discovery.service-name=${spring.application.name}

 4:在启动类上加上注解

5:查看是否有注册成功:输入localhost:8500

 

我们可以看到这里已经有一个product的模块服务,说明服务注册中已经将刚才的模块注册进来了 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/704967.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号