Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to add a jar package from a non-maven library to spring boot

Shulou Source: shulou.com Published: 2022-06-02 09:46:47 10月02日 Update

This article mainly explains "how to add jar packages in non-maven library" in spring boot. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to add jar packages in non-maven libraries in spring boot"!

Daily development uses oracle jar package, but not in maven central library; manual package introduction is required, but this does not take advantage of future development management of the project;

One way to do this is to package jar locally with the maven install command.

mvn install:install-file -DgroupId=com.zaxxer -DartifactId=HikariCP -Dversion=2.4.7 -Dpackaging=jar -Dfile=C:/Users/yangqc/Downloads/HikariCP-2.4.7.jar

Another way is to configure the maven packaging mechanism, introducing maven into the jar in the project, and introducing packaging resources when packaging; this is a complete solution to the problem;

project directory

The directory is src/main/lib, which can be adjusted according to personal habits

introducing dependency

com.oracle ojdbc7 12.1.0.2 system ${basedir}/src/main/lib/ojdbc7-12.1.0.2.jar

The scope and systemPath here cannot be less.

pom rewriting

org.apache.maven.plugins ---3.1 maven-compiler-plugin org.springframework.boot ----maven compiler for spring boot spring-boot-maven-plugin src/main/webapp src/main/resources src/main/java **/*.xml ----3.2 Add jar package directory and packaging target directory to resource src/main/lib BOOT-INF/lib/ **/*.jar

3.1 Add maven's default compiler to the compiler;

3.2 Add the jar package directory and package target directory to the resource; include resources elsewhere as well, as this is an override of the default resource attribute

At this point, I believe that everyone has a deeper understanding of "how to add jar packages in non-maven libraries" to spring boot, so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Directories libraries compilers compilers content projects methods goals resources learning development utility deeper personal central location interests commands practicality reality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL Shulou Technology Docker Apple