How to add local jar files to a Maven project

Опубликовано: 30 Сентябрь 2024
на канале: ICT Trainer
1,456
5

Two ways of doing this;
1. mvn install:install-file -Dfile=path/to/your.jar -DgroupId=your.groupId -DartifactId=your.artifactId -Dversion=your.version -Dpackaging=jar
2. If you want to use the ${basedir} variable in your Maven pom.xml file to reference local JAR files relative to your project's base directory, you can follow these steps:

Create libs Directory: Within your project directory, create a directory named libs where you will store your local JAR files.

Place JAR Files in libs Directory: Copy your local JAR files into the libs directory you just created.

Add Dependencies to pom.xml using ${basedir}:

In your pom.xml, you can use the ${basedir} variable to reference the base directory of your Maven project. Here's how you can include a local JAR file dependency using ${basedir}: