SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)

导读:本篇文章讲解 SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九),希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)

问题背景

从零开始学springcloud微服务项目
注意事项:

  • 约定 > 配置 > 编码
  • IDEA版本2021.1
  • 这个项目,我分了很多篇章,每篇文章一个操作步骤,目的是显得更简单明了
  • controller调service,service调dao
  • 项目源码以及sentinel安装包

项目搭建

1 新建公共模块module
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)
2 选择JDK1.8
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)
3 输入module名:cloud-api-commons
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)
4 引入pom依赖

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <artifactId>springcloud2022</artifactId>
        <groupId>com.yg</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>cloud-api-commons</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.1.0</version>
        </dependency>
    </dependencies>

</project>

5 在cloud-consumer-order80和cloud-provider-payment8001的pom里面添加公共依赖

        <!-- 引入自己定义的api通用包,可以使用Payment支付Entity -->
        <dependency>
            <groupId>com.yg</groupId>
            <artifactId>cloud-api-commons</artifactId>
            <version>${project.version}</version>
        </dependency>

6 把公共代码复制到cloud-api-commons模块,删除cloud-consumer-order80和cloud-provider-payment8001的公共代码
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)
7 整体目录结构
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)

8 使用maven进行install构建cloud-api-commons
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)

9 启动cloud-consumer-order80和cloud-provider-payment8001使用postman测试:http://localhost/consumer/payment/create?serial=ooo
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)

SpringCloud无介绍快使用,Seata处理分布式事务(二十五)
SpringCloud无介绍快使用,sentinel服务熔断功能(二十四)
SpringCloud无介绍快使用,sentinel注解@SentinelResource的基本使用(二十三)
SpringCloud无介绍快使用,sentinel热点key限流与系统规则的基本使用(二十二)
SpringCloud无介绍快使用,sentinel熔断降级和限流的基本使用(二十一)
SpringCloud无介绍快使用,Nacos集群和Nginx代理(二十)
SpringCloud无介绍快使用,nacos配置中心的基本使用(十九)
SpringCloud无介绍快使用,nacos注册中心的基本使用(十八)
SpringCloud无介绍快使用,gateway通过微服务名实现动态路由(十七)
SpringCloud无介绍快使用,gateway的基本使用(十六)
SpringCloud无介绍快使用,Ribbon负载均衡工具与OpenFeign的使用(十五)
SpringCloud无介绍快使用,使用Zookeeper替换Eureka服务注册与发现(十四)
SpringCloud无介绍快使用,服务发现Discovery和Eureka自我保护(十三)
SpringCloud无介绍快使用,集群cloud-provider-payment8002搭建(十二)
SpringCloud无介绍快使用,集群Eureka服务注册中心cloud-eureka-server7002搭建(十一)
SpringCloud无介绍快使用,单机Eureka服务注册中心cloud-eureka-server7001搭建(十)
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)
SpringCloud无介绍快使用,新建子module消费者订单模块(八)
SpringCloud无介绍快使用,热部署devtools配置(七)
SpringCloud无介绍快使用,子module提供者支付微服务业务开发(六)
SpringCloud无介绍快使用,新建子module提供者支付微服务yml整合和新建启动类(五)
SpringCloud无介绍快使用,新建子module提供者支付微服务pom整合(四)
SpringCloud无介绍快使用,springcloud父工程pom文件整理(三)
SpringCloud无介绍快使用,IDEA新建springcloud父工程(二)
SpringCloud无介绍快使用,与Spingboot之间的兼容版本选择(一)

作为程序员第 176 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …
SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)SpringCloud无介绍快使用,新建cloud-api-commons公共模块module(九)

Lyric: 告诉我印地安的传说

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/110699.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!