How Maven packs a local dependency package

Source: Internet
Author: User
Tags maven central

Some jar packages are not available in the MAVEN Central Library, so how do you use them in your project?

Suppose we need to use: Apache-ant-zip-2.3.jar

Place the jar package in the project's Lib directory, for example:

Add a reference to the jar inside the Pom.xml, for example:

<dependency>
<groupId>org.apache</groupId>
<artifactId>apache-ant-zip</artifactId>
<version>2.3</version>
<scope>system</scope>
<systemPath>${basedir}/lib/apache-ant-zip-2.3.jar</systemPath>
</dependency>

This will allow you to use Apache-ant-zip-2.3.jar in your project!

Here's the question of how to include Apache-ant-zip-2.3.jar in a project when it's packaged into a war.

In fact, in the pom.xml inside a configuration can be, for example:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>${project.artifactId}</warName>
<webResources>
<resource>
<directory>lib/</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>

Of course, in the include, you can also package other files, such as xml,properties and other configuration files.

After packing, I found that Apache-ant-zip-2.3.jar was already in the war package.

Done!

A pot of wine between flowers, alone without a blind date.

A toast to the moon, the shadow into three people.

Wood elder brother's articles are based on their own practice, you can pass: "E-Mail protected " contact.

How Maven packs a local dependency package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.