May 26, 2021 Maven
Now, as you know, Maven's dependency management uses the Maven-warehouse concept. B ut what if dependencies cannot be satisfied in remote and central warehouses? Maven uses the concept of external dependencies to solve this problem.
For example, let's make the following changes to a project created in the Maven - Create Engineering section:
Now, our engineering structure should look like the following:
Now that you have your own library, it usually contains jar files that no repository can use and maven can't download. If your code is using the library, Maven's build process will fail because it cannot be downloaded or referenced during the compilation phase.
To handle this situation, let's add this external dependency to the maven pom .xml.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.bank</groupId>
<artifactId>consumerBanking</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>consumerBanking</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ldapjdk</groupId>
<artifactId>ldapjdk</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\lib\ldapjdk.jar</systemPath>
</dependency>
</dependencies>
</project>
In the example above, the second element,
<dependency>
illustrates the key
concepts of
external dependency.
<dependencies>
Hopefully now that you know about external dependencies, you will be able to specify them in your Maven project.