Adding local jar files to a Maven project

I was developing a project with spring and maven, however when performing the build I came across a strange error



org.springframework.beans.factory.unsatisfieddependencyexception error creating bean with name 


Enter fullscreen mode Exit fullscreen mode

Even though my jar is in the build path, the error persisted, I tried to install it with the java -cp of life, but the problem persisted, that’s when I tried something a little different, directly add the dependency in pom.xml, after all it is an abstraction of the manifest in spring application

Solution

There are many ways to add local jar files to a Maven project:

  • Install manually the JAR into a local Maven repository use this command: “`bash

mvn install:install-file –Dfile=C:\dev\app.jar -DgroupId=com.mh.tutorial-DartifactId=my-example-app -Dversion=1.0

Now, add the dependency to your Maven project by adding these lines to your **pom.xml** file:
```xml


<dependency>
    <groupId>com.mh.tutorial</groupId>
    <artifactId>my-example-app</artifactId>
    <version>1.0</version>
</dependency>


Enter fullscreen mode Exit fullscreen mode

  • Adding directly the dependency as system scope Consider that the JAR is located in <PROJECT_ROOT_FOLDER>/lib. After this add the dependency in your pom.xml file as following: “`xml

com.mh.tutorial

<artifactId>my-example-app</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/lib/myCustomJAR.jar</systemPath>

Enter fullscreen mode Exit fullscreen mode


![](https://media1.giphy.com/media/6PopYBwOlKS8o/giphy.gif?cid=790b76113605f90875a8ba21a11cefe9e5a7351de1509bc0&rid=giphy.gif)

Enter fullscreen mode Exit fullscreen mode

原文链接:Adding local jar files to a Maven project

© 版权声明
THE END
喜欢就支持一下吧
点赞8 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容