当前位置: 首页 > news >正文

墙绘做网站推广有作用没站长工具怎么关掉

墙绘做网站推广有作用没,站长工具怎么关掉,网站文章做内链,网站推广的10种方法0. 引言 在单机架构下,我们只需要将我们的依赖在pom中引入。但是过渡到微服务架构后,会涉及到多模块引用相同的依赖,多模版之间依赖的版本太过分散难以管理的问题。 这就需要我们利用maven中依赖传递的特性,结合dependencyManage…

0. 引言
在单机架构下,我们只需要将我们的依赖在pom中引入。但是过渡到微服务架构后,会涉及到多模块引用相同的依赖,多模版之间依赖的版本太过分散难以管理的问题。

这就需要我们利用maven中依赖传递的特性,结合dependencyManagement标签来做好依赖的版本管理。下面我们就通过具体的案例来向大家演示如何在微服务架构中做好pom的管理规范。

1. 在父项目中实现版本管理
我们介绍的第一种版本管理的方案,就是在父项目中声明版本。

我们先来看我们的案例:

有一个微服务架构,包含商品模块product,订单模块order,网关模块gateway,还有一个公用模块commons。
其中商品模块、订单模块都需要引入nacos、spring web、seata、mybatis-plus、swagger、mysql、lombok依赖
订单模块中除了上述所说的依赖,还需要引入dynamic-datasource、openfeign依赖
网关模块需要引入nacos discovery、gateway、jwt、swagger、lombok依赖

1.1 在父项目中声明依赖版本
​​以下配置在父项目pom.xml中操作​​ 首先我们先将所需要的依赖的版本号定义为属性

<properties>
        <java.version>1.8</java.version>
        <maven.version>3.8.1</maven.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <spring-boot.version>2.3.7.RELEASE</spring-boot.version>
        <spring-cloud-alibaba.version>2.2.2.RELEASE</spring-cloud-alibaba.version>
        <seata-version>1.4.0</seata-version>
        <swagger.version>2.9.2</swagger.version>
        <mybatis-plus.version>3.4.2</mybatis-plus.version>
</properties>

其次我们在​​dependencyManagement​​标签中将所有的依赖做好版本声明

如果不知道这些标签的作用以及用法的,可以先看专栏的上一篇博客:
​springcloud:maven快速上手 | maven常用标签(十三)​​

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-alibaba-dependencies</artifactId>
                <version>${spring-cloud-alibaba.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>io.seata</groupId>
                <artifactId>seata-spring-boot-starter</artifactId>
                <version>${seata-version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba.nacos</groupId>
                <artifactId>nacos-client</artifactId>
                <version>${seata-version}</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>${swagger.version}</version>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>${swagger.version}</version>
            </dependency>
            <dependency>
                <groupId>com.baomidou</groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>${mybatis-plus.version}</version>
            </dependency>
        </dependencies> 
    </dependencyManagement>

这里咱们要注意的是,​​spring-boot-dependencies​​​和​​spring-cloud-alibaba-dependencies​​这两个依赖实际上并不是jar包,我们点击进去就可以知道,这是一个聚合项目,里面声明了常用的依赖的版本

我们通过引用这个线程的聚合项目,节省了大量常用依赖的版本管理

其次我们再在父项目中声明一下项目的jdk、maven版本以及编码格式。如果项目中有通用的maven插件配置,也可以在这里声明

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>

1.2 服务的公用依赖提取到commons模块中
​​以下配置在commons模块的pom.xml中操作​​ 基于这样的一个案例,我们首先知道的是商品模块和订单模块中都有很多相同的依赖,那么我们把这些相同的依赖添加到公用模块中,如果没有公用模块,可以创建一个,专用于存储公用的实体类、工具类、公共依赖登

首先我们需要声明父项目,以此使用父项目中声明的依赖版本

<parent>
        <artifactId>springcloud2</artifactId>
        <groupId>com.example</groupId>
        <version>1.0.0</version>
</parent>

其次将公用的依赖声明出来,这里会发现我们这里的依赖是没有声明版本的,这是因为我们已经在父项目中将版本声明好了。这也就是我们要做版本管理的意义所在

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency> 
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency> 
        <dependency>
            <groupId>io.seata</groupId>
            <artifactId>seata-spring-boot-starter</artifactId> 
        </dependency> 
        <dependency>
            <groupId>com.alibaba.nacos</groupId>
            <artifactId>nacos-client</artifactId> 
        </dependency> 
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
        </dependency> 
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
        </dependency> 
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        </dependency> 
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

1.3 商品、订单模块中引入commons模块
1、然后在商品模块和订单模块引入commons模块

<parent>
        <artifactId>springcloud2</artifactId>
        <groupId>com.example</groupId>
        <version>1.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>product-server-feign</artifactId>
    <version>${parent.version}</version>
    <name>product-server-feign</name>
    <description>product-server-feign</description>

    <dependencies>
        <dependency>
            <groupId>com.example</groupId>
            <artifactId>commons</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>

后续就可以只在commons中添加或者修改依赖,就能实现各个模块的公用依赖统一管理

需要注意的是:​​子项目中一定要用parent标签声明好父项目​​ 2、因为订单模块中还多了其他几个依赖,所以我们除了commons外还要在订单的pom中额外引入其他依赖

<parent>
        <artifactId>springcloud2</artifactId>
        <groupId>com.example</groupId>
        <version>1.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>order-server-feign</artifactId>
    <version>${parent.version}</version>
    <name>${project.artifactId}</name>

    <dependencies>
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.openfeign</groupId>
            <artifactId>feign-httpclient</artifactId>
        </dependency>

        <dependency>
            <groupId>com.example</groupId>
            <artifactId>product-server-feign</artifactId>
            <version>${parent.version}</version>
        </dependency>

    </dependencies>

3、commons中的公用依赖大部分网关模块都不需要,所以我们干脆就网关模块的依赖单独引入

<parent>
        <artifactId>springcloud2</artifactId>
        <groupId>com.example</groupId>
        <version>1.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>gateway-token</artifactId>
    <version>${project.parent.version}</version>
    <name>${project.artifactId}</name>

    <dependencies>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>
        <!-- JWT -->
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
        </dependency>
        <!--  swagger2      -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
        </dependency>
        <!-- swagger-ui -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
    </dependencies>

如上我们就针对我们整个项目的各个模块做好了依赖版本管理,如果需要查看源码可以文章最后的git地址中下载

2. 在聚合项目中实现版本管理
2.1 什么是聚合项目
所谓聚合项目,就是单独的一个空maven项目,只有pom文件,专门用于依赖的版本声明,其他的项目通过引入该聚合项目来实现依赖版本管理

这个比在父项目中进行版本管理更加凸显模块的专业化

2.2 实操
1、创建一个空maven项目,只保留pom.xml文件。将该项目的打包方式声明为pom

<packaging>pom</packaging>
1.
2、然后将上述的父项目中的​​dependencyManagement​​标签中的依赖管理添加到聚合项目的pom文件中

3、在商品服务、订单服务、网关服务、commons服务中引入该聚合项目,从而实现版本的统一管理

http://www.mmbaike.com/news/67590.html

相关文章:

  • 网站别人能打开我打不开官网建站多少钱
  • php靓号网站源码哪里有学市场营销培训班
  • 2345网址电脑版首页北京网络推广优化公司
  • 万全网站建设wl17581竞价托管外包
  • 门户网站建设的平台原创代写文章平台
  • 电子商务网站建设源码上海推广网络营销咨询热线
  • 创意设计赛道具体赛题是什么seo基础
  • 知名网站的org域名网站建设深圳公司
  • 网站方案原则模板网站建站哪家好
  • 科技企业网站源码百度站长工具数据提交
  • 伪静态wordpress东莞关键词排名优化
  • 哪个网站可以做体育主播百度投诉中心热线
  • 微信公众号影视网站怎么做手机网页制作软件
  • 关于建设工程如何监管的网站目前最好的引流推广方法
  • 好大夫官方网站网上预约挂号深圳外贸网站推广
  • 怎样制作html个人网站南京seo网站优化推广
  • 最主流的网页制作软件seo网站优化是什么
  • asp做微网站建立网站平台需要多少钱
  • 辽宁同鑫建设有限公司网站关键词优化报价
  • ipfs做网站火星培训机构收费明细
  • 如何搭建个人博客新站seo外包
  • 网站建设公司 佛山网站seo博客
  • 用html做网站代码seo检测优化
  • WordPress tag 目录seo优化排名推广
  • 做网站 数据库建站为应用技术
  • 做钢材的都用什么网站百度网盘app下载安装手机版
  • 专业做网站系统西安网站开发制作公司
  • 为企业做贡献的文章泸州网站优化推广
  • 怎么从阿里巴巴做网站seo推广策划
  • 营销型网站有哪些代表seo管理系统培训