0

I have to add some non-maven jars into a Spring boot project (MVC). Those jars are not built by maven or gradle or ..., and the don't have a pom.xml or build.gradle or ...

The jars are provided by a company, and they have no plan to host those jars on any maven repositories even their own (actually they don't have a private maven repo).

My project structure is like

my-app/
  |-lib
  |  |-some.jar
  |  |-other.jar
  |
  |-src/
     |-main/
     |   |-java/
     |   |-resources/
     |
     |-test/
         |-java/

I added a folder lib/ to the project root, and put those non-maven jars in it. The problem is how can I configure pom.xml to include those jars in classpath? Or can I put those jars in some other folder to avoid twisting maven configuration?

Aetherus
  • 8,720
  • 1
  • 22
  • 36
  • 2
    Possible duplicate of [Maven: best way of linking custom external JAR to my project?](http://stackoverflow.com/questions/5692256/maven-best-way-of-linking-custom-external-jar-to-my-project) – A_Di-Matteo Mar 16 '16 at 09:35
  • 1
    Possible duplicate of [Can I add jars to maven 2 build classpath without installing them?](http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them) – 1615903 Mar 16 '16 at 09:36
  • I've read that post, but can I add jars to classpath without installing those jars to my local maven repo? – Aetherus Mar 16 '16 at 09:36
  • check `system` for dependency. You have to be very careful, as jar file created this way is not portable by default – diginoise Mar 16 '16 at 09:42
  • I added `system`, but I didn't put those jars into java home because they depends on GSON. I tried `${basedir}/lib/some.jar` but failed in building. – Aetherus Mar 16 '16 at 09:59

1 Answers1

-3

You can do this :

For example i want to add ojdbc-7.jar on my repository, i go to my repository \USERFolder\Laptop_Login.m2\repository\ojdbc\ojdbc\7 and i create manually the path ojdbc\ojdbc\7\ and in the path 7 i put my File Jar.

dependency groupId ojdbc groupId artifactId ojdbc artifactId version 7 version dependency

between the tag's value of artifactId and the tag's value of version add a mince like this (ojdbc-7).

i think it's the better way to do.

  • 1
    "i think it's the better way to do.", well, I wouldn't say so, mvn install:install-file would do exactly the same, but not manually, less error-prone, more standard, but still less portable build – A_Di-Matteo Mar 16 '16 at 10:35