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

怎么选择丹徒网站建设广告推广

怎么选择丹徒网站建设,广告推广,怎么自己学着做网站,企业宣传册模版Maven进阶系列-继承和聚合 文章目录 Maven进阶系列-继承和聚合1. 继承2. 继承的作用2.1 在父工程中配置依赖的统一管理2.2 在父工程中声明自定义属性2.3 父工程中必须要继承的配置 3. 聚合4. 聚合的作用 1. 继承 Maven工程之间存在继承关系,例如工程B继承工程A&…

Maven进阶系列-继承和聚合

文章目录

  • Maven进阶系列-继承和聚合
    • 1. 继承
    • 2. 继承的作用
      • 2.1 在父工程中配置依赖的统一管理
      • 2.2 在父工程中声明自定义属性
      • 2.3 父工程中必须要继承的配置
    • 3. 聚合
    • 4. 聚合的作用

1. 继承

Maven工程之间存在继承关系,例如工程B继承工程A,工程C也继承了工程A

ProjectA的pom.xml

<?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"><modelVersion>4.0.0</modelVersion><groupId>com.xmc</groupId><artifactId>ProjectA</artifactId><packaging>pom</packaging><version>1.0-SNAPSHOT</version><modules><module>ProjectB</module><module>ProjectC</module></modules><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties></project>

ProjectB的pom.xml

<?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>ProjectA</artifactId><groupId>com.xmc</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>ProjectB</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties></project>

ProjectC的pom.xml

<?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>ProjectA</artifactId><groupId>com.xmc</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>ProjectC</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target></properties></project>

本质上是ProjectB和ProjectC的 pom.xml 中的配置
继承了ProjectA中 pom.xml 的配置。

这里提到了超级pom.xml,对于我们创建的一个maven工程,即便我们自己的pom.xm文件中没有明确指定一个父工程(父POM),其实也默认继承了超级POM,就好比JAVA类继承Object类一样。

maven官网关于超级POM的介绍:
https://maven.apache.org/pom.html#Inheritance
link

超级POM文件的位置:
例如,我使用的是maven 3.6.1版本:

打开这个jar包,可以看到超级POM文件:

超级pom.xml文件

<?xml version="1.0" encoding="UTF-8"?><!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
--><!-- START SNIPPET: superpom -->
<project><modelVersion>4.0.0</modelVersion><repositories><repository><id>central</id><name>Central Repository</name><url>https://repo.maven.apache.org/maven2</url><layout>default</layout><snapshots><enabled>false</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><name>Central Repository</name><url>https://repo.maven.apache.org/maven2</url><layout>default</layout><snapshots><enabled>false</enabled></snapshots><releases><updatePolicy>never</updatePolicy></releases></pluginRepository></pluginRepositories><build><directory>${project.basedir}/target</directory><outputDirectory>${project.build.directory}/classes</outputDirectory><finalName>${project.artifactId}-${project.version}</finalName><testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory><sourceDirectory>${project.basedir}/src/main/java</sourceDirectory><scriptSourceDirectory>${project.basedir}/src/main/scripts</scriptSourceDirectory><testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory><resources><resource><directory>${project.basedir}/src/main/resources</directory></resource></resources><testResources><testResource><directory>${project.basedir}/src/test/resources</directory></testResource></testResources><pluginManagement><!-- NOTE: These plugins will be removed from future versions of the super POM --><!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) --><plugins><plugin><artifactId>maven-antrun-plugin</artifactId><version>1.3</version></plugin><plugin><artifactId>maven-assembly-plugin</artifactId><version>2.2-beta-5</version></plugin><plugin><artifactId>maven-dependency-plugin</artifactId><version>2.8</version></plugin><plugin><artifactId>maven-release-plugin</artifactId><version>2.5.3</version></plugin></plugins></pluginManagement></build><reporting><outputDirectory>${project.build.directory}/site</outputDirectory></reporting><profiles><!-- NOTE: The release profile will be removed from future versions of the super POM --><profile><id>release-profile</id><activation><property><name>performRelease</name><value>true</value></property></activation><build><plugins><plugin><inherited>true</inherited><artifactId>maven-source-plugin</artifactId><executions><execution><id>attach-sources</id><goals><goal>jar-no-fork</goal></goals></execution></executions></plugin><plugin><inherited>true</inherited><artifactId>maven-javadoc-plugin</artifactId><executions><execution><id>attach-javadocs</id><goals><goal>jar</goal></goals></execution></executions></plugin><plugin><inherited>true</inherited><artifactId>maven-deploy-plugin</artifactId><configuration><updateReleaseInfo>true</updateReleaseInfo></configuration></plugin></plugins></build></profile></profiles></project>
<!-- END SNIPPET: superpom -->

2. 继承的作用

2.1 在父工程中配置依赖的统一管理

  • 在父工厂projectA的pom.xml中定义
<dependencyManagement><dependencies><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-core</artifactId><version>5.8.15</version></dependency></dependencies>
</dependencyManagement>
  • 然后在子工程projectC的pom.xml中使用的时候就不需要申明版本号,在父工程中统一管理jar包版本
<dependencies><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-core</artifactId></dependency>
</dependencies>

2.2 在父工程中声明自定义属性

<!-- 通过自定义属性,统一指定Spring的版本 -->
<properties><!-- 自定义标签,维护Spring版本数据 --><spring.version>6.0.6</spring.version>
</properties>

在需要的地方使用${}的形式来引用自定义的属性名:

<dependency><groupId>org.springframework</groupId><artifactId>spring-core</artifactId><version>${spring.version}</version>
</dependency>

2.3 父工程中必须要继承的配置

  • 父工程中的依赖
<dependencies>
。。。
<dependencies>

这里的依赖不是 dependencyManagement>中的依赖,dependencyManagement>是定义,并不引入依赖

  • 父工程中的构建

插件设置方法与前面的依赖极为相似,同样也有插件管理 pluginManagement,与 dependencyManagement 类似,这里给出一个 parent 中设置的样例模板

<build><plugins><!-- 声明必须继承的插件 --></plugins><pluginManagement><plugins><!-- 声明可供选择是否继承的插件 --></plugins></pluginManagement>
</build>

3. 聚合

在Maven中,聚合(aggregation)是指将多个项目或模块组合成一个更大的项目的过程。通过使用聚合,可以将多个相关的项目捆绑在一起,以便一次性构建和部署。

在Maven中,可以使用<modules>元素来定义聚合关系。在父项目的pom.xml文件中,可以使用<modules>元素列出所有要聚合的项目或模块。例如:

<modules><module>ProjectB</module><module>ProjectC</module>
</modules>

4. 聚合的作用

  • 一键执行 Maven 命令:很多构建命令都可以在“总工程”中一键执行。

以install 命令为例:Maven 要求有父工程时先安装父工程;有依赖的工程时,先安装被依赖的工程。我们自己考虑这些规则会很麻烦。但是工程聚合之后,在总工程执行 mvn install 可以一键完成安装,而且会自动按照正确的顺序执行。

  • 配置聚合之后,各个模块工程会在总工程中展示一个列表,让项目中的各个模块一目了然。
http://www.dinnco.com/news/8019.html

相关文章:

  • 网站关键词优化排名软件系统广州婚恋网站排名
  • 独立的手机网站seo关键词排名优化怎么样
  • 网站建设 证书深圳做推广哪家比较好
  • 开封市住房和城乡建设局网站免费网站自助建站系统
  • 做网站总结体会现在网络推广方式
  • 国家发改委网站开发区秦洁婷seo博客
  • 网站建设美工的职位要求网站seo外链
  • 公众号开发者模式后自动回复抚州seo排名
  • 政务网站党风廉政建设栏目seo网络营销
  • 网站导航页面制作站长工具网站排名
  • 教育机构有哪些品牌seo主要做什么
  • 河西网站建设开发济南网络营销外包
  • 招商网站建设推广百度秒收录神器
  • 汽车之家网页版入口官网搜索引擎优化简历
  • 做受免费网站今日新闻头条
  • 网络管理系统有哪些seo管理是什么
  • 郑州建设网站报价北京培训学校
  • 手机传奇网站模板下载深圳有实力的seo公司
  • 购物网站需要做的功能如何做好网络营销推广
  • 青岛城市建设委员会网站百度广告联盟平台
  • 17zwd一起做业网站百度站长平台官网登录入口
  • 互联网网站开发服务合同代发百度帖子包收录排名
  • 做网站什么价格旅游新闻热点
  • 阿里云免费网站建设免费的app推广平台
  • 能用的手机网站百度企业推广
  • 网站建设 黑龙江新网店怎么免费推广
  • 机械公司网站建设中国十大经典广告
  • 帝国cms仿站工具搜索推广代运营
  • 欧盟理事会seo白帽优化
  • 郑州做网站外包的公司互联网公司排名2021