Father and son created maven engineering polymer and inheritance

First, the basic structure

1. Create a parent project maven

     Father works are packaged must pom, allows subclasses to inherit

      代码: <packaging>pom</packaging>

    groupId general is the package name, company name contains

      代码:<groupId>com.baidu</groupId>

    The artifactId member, typically the parent module project name, sub-module name service module corresponding generally

    <artifactId>baidu</artifactId>

2, create a sub-module

     Creating a sub-project     

     A packaging: jar

           代码: <packaging>jar</packaging>

     Member artifactId: the name of the corresponding service module

          代码:  <artifactId>baidu-module-order</artifactId>

    Note: The sub-project coordinates simply write artifactId label, groupId labels directly inherited from the parent label, so no need to write sub-module groupId

3, dependencies between sub-projects

    As we created two submodules A and B, if B A module to use an interface module or a class, we will need to coordinate dependency module pom tag A and B dependent file into.

     If the order requires the user module (user), then added to the dependent code as follows:

<dependencies>
    <dependency>
        <groupId>com.baidu</groupId>
        <artifactId>baidu-module-user</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

Second, the introduction of several important attributes

<!-- 项目当前版本,格式为:主版本.次版本.增量版本-限定版本号 --> 
    <version> 1.0-SNAPSHOT </version> 

<!-- 项目产生的构件类型,例如jar、war、ear、pom。插件可以创建他们自己的构件类型,所以前面列的不是全部构件类型 --> 
    <packaging> jar </packaging> 

<!-- 项目的名称, Maven产生的文档用 --> 
    <name> xxx-xxx</name> 

<!-- 项目主页的URL, Maven产生的文档用 --> 
    <url> http://maven.apache.org </url> 

<!-- 项目的详细描述, Maven 产生的文档用。 当这个元素能够用HTML格式描述时(例如,CDATA中的文本会被解析器忽略,就可以包含HTML标签), 不鼓励使用纯文本描述。如果你需要修改产生的web站点的索引页面,你应该修改你自己的索引页文件,而不是调整这里的文档。 --> 
    <description> A maven project to study maven. </description> 

Specific elements can refer to: POM explain all the elements

 

 

Guess you like

Origin blog.csdn.net/m0_37668842/article/details/91438944