Maven-three project packaging methods-jar, war, pom

1. pom project:

Used in the parent project or aggregation project. Used for version control of jar packages. It must be specified that the packaging method of this aggregation project is pom

2.war project:

Will be packaged into war and published on the server project. Such as website or service. In the SpringBoot project, as long as we add the web starter to the dependency, we don't need to add the packaging method. Maven will automatically help us identify this project as a war project. If it is not a springBoot project, you need to indicate that this project is a web project.

3.jar project:

Will be packaged into a jar for use as a jar package. In the project, if it is not specified, the default is to package it into a jar project, we can also add the specified packaging method to jar.

Take Taotao Mall as an example:
Insert picture description here

One. pom project

  1. taotao-parent:

Taotao-parent is the parent project of the entire project, it is a pom project. It is used for version control of the entire project, that is, the versions of all jar packages to be used in the project are centrally managed by the parent project. In this way, you do not need to write the version number when writing maven dependencies in other project pom files. Of course, all projects must inherit it first.

  1. taotao-manager:

Create taotao-manager to do aggregation project, it is also a pom project. Create four models: taotao-manager-pojo, taotao-manager-dao, taotao-manager-service, taotao-manager-web, and 4 independent maven projects will be automatically generated. Convergence engineering is just a tool used to help other modules build, and has no substantial content in itself. The specific code of each project is still written in the generated project.

  1. The meaning of using aggregation engineering taotao-manager is:

Originally, these modules were also independent projects. Now they are aggregated into taotao-manager, so that when we build the project, we only need to build taotao-manager. We only need to use maven to build this aggregation project taotao-manager without worrying about the construction of the module. For example, when installing, just install taotao-manager. All in all is to simplify the operation. The normal coding work is still in the corresponding taotao-manager-pojo, taotao-manager-dao, taotao-manager-service, taotao-manager-web. During the project.

2. war project

  1. taotao-rest, taotao-portal these

These projects are to be deployed on the server, so they must be packaged into war form. Some of these projects are directly accessed by users through browsers, and some are called by other projects through publishing services.

Three.jar project

  1. taotao-common

This is the project packaged into a jar. It is to store some classes and tool classes that other projects will use. We can refer to it in the pom files of other projects, which is no different from referencing other jar packages.

<dependency>
    <groupId>com.taotao</groupId>
        <artifactId>taotao-common</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

Guess you like

Origin blog.csdn.net/weixin_44556968/article/details/109890845