Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Maven Importing External Dependencies

Maven Importing External Dependencies

If we need to import third-party library files into the project, how should we do it?

The dependencies list in pom.xml lists all external dependencies needed to build our project.

To add a dependency, we generally first add a lib folder under the src folder, then copy the jar files needed by your project into the lib folder. We use ldapjdk.jar, which is a helper library for LDAP operations:

Then add the following dependency to the pom.xml file:

<

dependencies

<

dependency

<

groupId

ldapjdk

</

groupId

<

artifactId

ldapjdk

</

artifactId

<

version

1.0

</

version

<

scope

system

</

scope

<

systemPath

${basedir}\src\lib\ldapjdk.jar

</

systemPath

</

dependency

</

dependencies

The complete pom.xml file code is as follows:

<

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