Method and steps of packaging and deployment of Maven multi module project

The general Maven multi module engineering structure is shown in the figure below. The figure is divided into Dao data layer and upper web layer (of course, there can also be service layer). When dividing multiple modules, the Dao layer is generally packaged with jar and the web layer is packaged with war. When deploying the war package, it is found that Dao exists in the Lib package directory in the form of jar package. It will be troublesome to modify the relevant configuration on the deployment server. Therefore, the following method of merging and packaging with Maven is studied:

1. Ensure Dao POM XML has the following configuration

2. Execute in Dao Directory: MVN clean install - dmaven test. Skip = true to generate the jar package

3. In Web Engineering POM XML add the following plug-in configuration

The above plug-in indicates that dao-1.0 will be used Unzip the jar into the target / classes directory of the web project (i.e. the source directory of the project compilation)

4. Running the web project, you can find that Dao related configuration files and source code have been merged. (note that Dao jars will also be included in the Lib of the default war package.)

If you also need to package and deploy the war project with jar, you can use the web project POM Add a jar packaging plug-in to XML

After joining, re execute the MVN install command under the web, and the web.inf will be generated in the target / WEB-INF / lib directory Jar file. Jar does not contain properties and XML files (excluding excludes, all files will be packaged by default).

In the above case, the configuration file is not packaged, so the configuration file needs to be copied:

Through the above configuration method, you can copy the configuration file to the target / WEB-INF / classes directory

Through the above configuration, there are no other dependent jar packages for web project deployment, so you need to copy the jar package (and remove the dependent Dao):

Through the above steps, you can see the deployment structure of Web general engineering in the target directory:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>