Maven project introduces local jar package method

If you need to introduce third party packages, such as express birds, Alipay, WeChat and other jar packages (of course, it is possible to directly provide Maven dependence).

If you download it locally, how can you integrate it into your Maven project?

There are many ways. Here are four ways

1. Upload to Maven central warehouse

If you are willing to toss around, you can also make fun of it. Please refer to how to release jar package to Maven central warehouse (it’s really troublesome)

For example, this is the jar package I manually uploaded to Maven central…

Advantages: it can be directly introduced into pom.xml, and there is no problem with packaging deployment

Disadvantages: uploading is complex and troublesome (creating work orders, generating secret keys, etc.)

2. Build Maven private server

Upload it manually on the background management page, and then import pom.xml

View by upload methodMaven private server nexus upload third-party jar packages and download

advantage: download speed is fast, Maven aggregation project is more applicable, and deploy can be applied internally. There is no problem with packaging and deployment

shortcoming: compared with the first one, it is more troublesome and takes up local server resources

3. Traditional methods

Java se routine

Create a new lib package and then import it (eclipse directly builds path) (idea is more troublesome: file → project structure → libraries → + jar package)

Maven project introduces local jar package method

4. System attribute of POM file scope

advantage: it can be imported directly after configuration. Maven reimport is OK

shortcoming: there is no disadvantage, but the configurator takes some time


To introduce the followingarcsoft-sdk-face-


1. Customize the directory. Here, create a new lib folder in the root directory of the project and put the jar in it

Maven project introduces local jar package method

2. Introduced in pom.xml


be careful:

  • Groupid: Custom
  • Artifactid: Custom
  • Version: Custom
  • Scope: must be system
  • SystemPath: the path of the jar package (there will be a prompt when the idea is written)

Through the above methods, there is no problem in the development environment, and there will be no case where any package cannot be found

However, Maven project deployment is generally packaged and released, so packaging requires additional configuration (no additional processing is required in the first and second methods above)

Processing packaging

The following configuration needs to be made during packaging. It needs to be introduced through the resource tag, and the location is build → resources → resource

  • Directory: specify the location of the Lib folder. Since it is relative to the project root directory, you can write lib directly
  • Targetpath: the location of the package folder. Just write boot-inf / lib or WEB-INF / lib. [slash (/) can be added or not. If it is Mac, write. /]
  • Includes: generally, it ends in jar and is written*/.jar

This work adoptsCC agreement, reprint must indicate the author and the link to this article