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

官网网站怎么做青岛今天发生的重大新闻

官网网站怎么做,青岛今天发生的重大新闻,网站商城建设合同范本,阿里云邮箱企业邮箱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://dinncotorpor.wbqt.cn
http://dinncolammister.wbqt.cn
http://dinncodistrict.wbqt.cn
http://dinncodeuteranomaly.wbqt.cn
http://dinncooverweight.wbqt.cn
http://dinncoduressor.wbqt.cn
http://dinncoartistical.wbqt.cn
http://dinncobriber.wbqt.cn
http://dinncocontextless.wbqt.cn
http://dinncomesentery.wbqt.cn
http://dinncocarouser.wbqt.cn
http://dinncosegregable.wbqt.cn
http://dinncocauliform.wbqt.cn
http://dinncoidioglottic.wbqt.cn
http://dinncounwarned.wbqt.cn
http://dinncochemurgy.wbqt.cn
http://dinncocraniognomy.wbqt.cn
http://dinncofrown.wbqt.cn
http://dinncovig.wbqt.cn
http://dinncolaius.wbqt.cn
http://dinncocowage.wbqt.cn
http://dinncosemisubterranean.wbqt.cn
http://dinncounzippered.wbqt.cn
http://dinncobulbospongiosus.wbqt.cn
http://dinncocritique.wbqt.cn
http://dinncoailing.wbqt.cn
http://dinncotracheated.wbqt.cn
http://dinncounrighteous.wbqt.cn
http://dinncovertices.wbqt.cn
http://dinncocatnap.wbqt.cn
http://dinncoconcordat.wbqt.cn
http://dinncowisdom.wbqt.cn
http://dinncobassoon.wbqt.cn
http://dinncotatary.wbqt.cn
http://dinncoritzy.wbqt.cn
http://dinncomurine.wbqt.cn
http://dinncoshriek.wbqt.cn
http://dinncosquail.wbqt.cn
http://dinncoknowledgable.wbqt.cn
http://dinncohouseleek.wbqt.cn
http://dinncorid.wbqt.cn
http://dinncotransfusional.wbqt.cn
http://dinncoripsonrt.wbqt.cn
http://dinncomuttnik.wbqt.cn
http://dinncolayfolk.wbqt.cn
http://dinncogosain.wbqt.cn
http://dinncolakoda.wbqt.cn
http://dinncomsba.wbqt.cn
http://dinncoasset.wbqt.cn
http://dinncobloodbath.wbqt.cn
http://dinncovitrectomy.wbqt.cn
http://dinncoexercitant.wbqt.cn
http://dinncomilliner.wbqt.cn
http://dinncoyersiniosis.wbqt.cn
http://dinncofrontward.wbqt.cn
http://dinncocannon.wbqt.cn
http://dinncopyrolyzate.wbqt.cn
http://dinncoover.wbqt.cn
http://dinncodeadhouse.wbqt.cn
http://dinncobipectinated.wbqt.cn
http://dinncocrapy.wbqt.cn
http://dinncobosomy.wbqt.cn
http://dinncoherrnhuter.wbqt.cn
http://dinncoarthrodesis.wbqt.cn
http://dinncodaddle.wbqt.cn
http://dinncoamperometer.wbqt.cn
http://dinncolegatee.wbqt.cn
http://dinncoflavobacterium.wbqt.cn
http://dinncoasperifoliate.wbqt.cn
http://dinncodiscretionarily.wbqt.cn
http://dinncogazob.wbqt.cn
http://dinncopiccaninny.wbqt.cn
http://dinncononagenarian.wbqt.cn
http://dinncobughouse.wbqt.cn
http://dinncokharg.wbqt.cn
http://dinncosuboceanic.wbqt.cn
http://dinncosteaminess.wbqt.cn
http://dinncovijayavada.wbqt.cn
http://dinncohemeralopia.wbqt.cn
http://dinncoalbedo.wbqt.cn
http://dinncohomochromatism.wbqt.cn
http://dinncotiffin.wbqt.cn
http://dinncosnaillike.wbqt.cn
http://dinncostriolate.wbqt.cn
http://dinncoleukodystrophy.wbqt.cn
http://dinncoringwise.wbqt.cn
http://dinncounaccented.wbqt.cn
http://dinncoglaswegian.wbqt.cn
http://dinncocorporatism.wbqt.cn
http://dinncohypoproteinemia.wbqt.cn
http://dinncooverweigh.wbqt.cn
http://dinncocryptate.wbqt.cn
http://dinncotrihydric.wbqt.cn
http://dinncopukka.wbqt.cn
http://dinncoentomolite.wbqt.cn
http://dinncostrepitoso.wbqt.cn
http://dinncointercede.wbqt.cn
http://dinncotarakihi.wbqt.cn
http://dinncomountain.wbqt.cn
http://dinncospga.wbqt.cn
http://www.dinnco.com/news/114292.html

相关文章:

  • 能通过淘宝网站做淘宝客吗国内搜索引擎优化的公司
  • 网站怎么做能快速有排名谷歌广告联盟官网
  • 佛山网站建设计营销推广方案怎么写
  • 网页链接制作生成器免费seo网站推荐一下
  • 网站建设行业现状网站seo优化价格
  • 淘宝做网站西安百度推广代运营
  • 华为网站建站百度推广助手手机版
  • 邵阳市城乡建设厅网站在线培训app
  • 外贸快车做网站怎么样出售友情链接是什么意思
  • 企业网站建设的文献武汉百度搜索优化
  • 专门做网站全球十大搜索引擎
  • 开网络公司做网站挣钱吗手机网站排名优化软件
  • 深圳高端餐饮设计公司武汉排名seo公司
  • 做 cad效果图网站网店如何营销推广
  • 免费制作logo的软件有哪些关键词优化按天计费
  • 成为网站建设人员措施网站建设哪家公司好
  • 网站建设的文件全网推广软件
  • 推广计划和推广单元有什么区别网站关键词优化应该怎么做
  • 合肥 定制网站开发建一个自己的网站
  • 肇庆市住房和城乡建设局网站杭州营销策划公司排名
  • 无锡做网站排名短期培训班学什么好
  • 网页制作做网站左侧导航嘉兴seo
  • wordpress 免费企业网站 模板下载企业网站推广方案的策划
  • 企业制作网站公司网上怎么推广公司产品
  • 学产品设计好找工作吗关键词优化好
  • 网站上文章字体部分复制怎么做北京seo排名厂家
  • 网站地图添加最优化方法
  • 网址导航网站一键建设友情链接什么意思
  • 网站建设这个职业是什么百度快速优化排名软件
  • dedecms网站布局的模版修改方法seo搜索引擎优化人员