简体   繁体   中英

Maven: copy local jar to target dir

I want a local jar located in C:/myLibs/TDKLogging/TDKLogging-2.1.6.jar to be copied to my target dir when generating the war, so I modified my pom as follows:

<repositories>
    <repository>
        <id>JBossNexus</id>
        <name>JBoss Nexus Repository Manager</name>
        <layout>default</layout>
        <url>https://webgate.tdk.com/JBoss/nexus/content/groups/public</url>
    </repository>

    <repository>
       <id>my-local-repo</id>
       <url>file://C:/myLibs/</url>
    </repository>
    </repositories>

    <dependencies>


        <dependency>
            <groupId>tdk.com.iot.log</groupId>
            <artifactId>TDKLogging</artifactId>
                <version>2.1.6</version>
            <type>jar</type>
        </dependency>
..

But I got this error

  Could not find artifact tdk.com.iot.log:TDKLogging:jar:2.1.6 in tdkPublicRepository (https://webgate.tdk.com/JBoss/nexus/content/groups/public) 

How to tell maven to search the artifact in a specific repo ???? Can a project work with more than 1 repo at the same time ???? because I only have 1 jar in the local repo, the others ones are stored in the public repo

you may have more than one repo specified.

<repositories>
  <repository>
     <id>Webgate repository</id>
     <url>https://webgate.tdk.com/JBoss/nexus/content/groups/public/</url>
  </repository>
  <repository>
     <id>JBoss repository</id>
     <url>http://repository.jboss.org/nexus/content/groups/public/</url>
  </repository>
  <repository>
     <id>java.net</id>
     <url>https://maven.java.net/content/repositories/public/</url>
  </repository>
</repositories>

What about your particular situation - you have to add your jar and pom to your local repository. You have to run few commands.

Check this How to include custom library into maven local repository?

and this Guide to installing 3rd party JARs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM