1


The common ways of including external non-maven jar in the classpath of your Maven project is to either use "addjar-maven-plugin" (which I have not been able to get to compile maven with) or "mvn install:install-file" and then adding a dependency section for the external JAR. This approach essentially installs client JAR in your repo and makes it available in classpath for maven. But is there a better way to do this (or) are the options mentioned above the only ones available? I just want the external JAR to be added to classpath for component scanning by Spring but do not want the JAR itself to be added to my repo as it is client's JAR? I hope this is a valid case (if not, kindly explain)
Thanks,
Paddy

1
  • 1
    You can use system <scope> with <systemPath>, see this answer for more details. Commented Feb 5, 2013 at 1:06

1 Answer 1

5

You can create lib folder under your project's src folder and reference this folder as maven repository.

<repository> <id>local</id> <url>file://${basedir}/src/lib</url> </repository> 

Then you should add dependency to your jar in your pom.xml

<dependency> <groupId>com.company</groupId> <artifactId>dependency</artifactId> <version>1.0</version> </dependency> 

After that your should rename jar file and place it on following path src/lib/com/company/dependency/1.0/dependency-1.0.jar . This path depends on how you want to reference your jar.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.