Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to introduce local jar package into maven project

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to introduce the local jar package into the maven project. The introduction in this article is very detailed and has certain reference value. Interested friends must read it!

1 cause

In the process of docking with some third-party vendors, we will occasionally encounter SDK packages that are not available with maven provided by the other party (I hate this behavior for open source activists).

How should we deal with this situation? in fact, the solution is very simple:

Introducing local jar into pom

Local jar is included when packing

Let's see how it works.

Although idea can be added to the project configuration, it will report an error when packing, and the relevant processing plan will no longer be considered.

2 solution

First of all, the ultimate solution is to upload the jar package to your maven private server.

For friends who don't have their own private service, this is nonsense. Let's take a look at the actual situation.

2.1Introducing pom

The following is my personal solution, first introduce the project directory:

Project |-src |-lib |-pig.jar |-pom.xml

We can directly add the following references to pom:

Cn.com.pig pig 1.0 system ${project.basedir} / lib/pig.jar

For groupId, version and other contents, you can open the jar package in idea and check the MANIFEST.MF in it.

2.2 Spring Boot packaging processing

After the introduction of pom is completed, execute the package command of maven directly, and the pig.jar will not be found. Let's continue to modify it:

Org.springframework.boot spring-boot-maven-plugin true 2.3Expands: Spring Boot packages to add other resources

When interacting with hardware devices, we may need to introduce some dll files in addition to the basic jar package (of course, the author recommends that these dll be placed outside the project and handled through absolute paths when referenced)

You can add these resources in the following ways:

Dll/ BOOT-INF/dll/ *. *

Explain the above parameters below:

Directory: local path, dll is project/dll

TargetPath: the path in the jar package after packaging is completed. If it doesn't start with /, it will be appended under the classes directory by default. For example, dll will be actually generated in / BOOT-INF/classes/dll, and the path entered above will be packaged to / BOOT-INF/dll.

Include: include files, *. * for all

The above is all the contents of the article "how to introduce the local jar package into the maven project". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report