Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

how to add external jar to maven webapp project

I have a Spring roo project (basically a maven project). I want to add dropbox sdk to the project, problem is it's not in maven. I added the following files

    <dependency>
        <groupId>com.dropbox</groupId>
        <artifactId>dropbox-sdk</artifactId>
        <version>1.3.1</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/libs/dropbox-java-sdk-1.3.1.jar</systemPath>
    </dependency>

It solved the compile error, but when i run the project, in Spring Tool Suite, the jar files are not added to war lib folder. How do I make maven add my external jar files to my the war lib folder?

I don't want to install the jar in maven since, I have to install it in all the machines that uses the project

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I finally found a neat solution, which is a lot easier to implement. You add an in-project repository inside the java project and link to it in the pom.

You add an in-project repository in maven like this:

<repository>
    <id>in-project</id>
        <name>In Project Repo</name>
        <url>file://${project.basedir}/libs</url>
</repository>

Then create a folder structure in the root folder of your project that looks something like this

/groupId/artifactId/version/artifactId-version.jar

and add the dependency as you would normally do.

This approach has the least amount of code and work required, and if that library ever gets add into a maven repository you can always remove your in-project repository.

http://bit.ly/OGVHSN


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...