Adding local jar in maven using a local repository

Sometimes the library you’re trying to use don’t have any Maven repository.
You can solve this problem without creating you own repository server.

Simply run your repository on localhost pointing into your project.

Setting up local Maven Repository


<project [...]>



Make sure the jar is present at the root of your project into /repo/com/jarName/1.5.3/jarName-1.5.3.jar

Path local Maven repository

Path local Maven repository

Using maven normally

Now you can run traditional maven command such as “mvn build”, “mvn eclipse:eclipse” etc…
The jar within your local repository will be “downloaded” in your M2_HOME directory and use as a normal repository.

The deprecated way: using the “scope system” dependency

I don’t encourage you using it. It don’t behave the same way as standard repository.
Meaning you might run into strange problem, as I did. But I might be interesting for quick prototyping.

  • using “scope == system”

Where ${project.basedir} is the root of your project.
But you can use a different path and making it a nightmare for your team…

  • Antonio

    Could you please confirm this solution is still valid? I followed it literally but Maven says it can’t locate the jar file.

    • martin-magakian

      I don’t think this solution will ever expire. At least not until a very long time

      • daphne

        I got the can’t locate the jar file as well.
        But it is working with Maven2, but not maven3