Maven fails to find local artifact

后端 未结 14 1596
Happy的楠姐
Happy的楠姐 2020-12-04 11:40

Occasionally maven complains that a particular dependency, which is built and packaged locally, cannot be found in the local repository while building another project that h

相关标签:
14条回答
  • 2020-12-04 12:09

    The local Maven repo tracks where artifacts originally came from using a file named "_maven.repositories" in the artifact directory. After removing it, the build worked. This answer fixed the problem for me.

    0 讨论(0)
  • 2020-12-04 12:09

    When this happened to me, it was because I'd blindly copied my settings.xml from a template and it still had the blank <localRepository/> element. This means that there's no local repository used when resolving dependencies (though your installed artifacts do still get put in the default location). When I'd replaced that with <localRepository>${user.home}\.m2\repository</localRepository> it started working.

    For *nix, that would be <localRepository>${user.home}/.m2/repository</localRepository>, I suppose.

    0 讨论(0)
  • 2020-12-04 12:10

    Even in offline mode, maven will check remote repositories if there is a _remote.repositories marker for the dependency. If you need to operate in offline mode, you may need to delete these files.

    The simple shell command below deletes these marker files. This is safe to do if you only use offline mode for the machine. I would NOT do this on a machine that needs to pull files down from the web.

    I have used this strategy on a build server that is disconnected from the web. We have to transfer the repository to it, delete the marker files and then run in offline mode.

    On Linux / Unix you can delete the remote repository marker files this way:

    cd ~/.m2
    find . -name "_remote.repositories" -type f -delete
    
    0 讨论(0)
  • 2020-12-04 12:10

    This happened because I had http instead of https in this:

    <repository>
        <id>jcenter</id>
        <name>jcenter-bintray</name>
        <url>https://jcenter.bintray.com</url>
    </repository>
    
    0 讨论(0)
  • 2020-12-04 12:12

    One of the errors I found around Maven is when I put my settings.xml file in the wrong directory. It has to be in .m2 folder under your user home dir. Check to make sure that is in the right place (along with settings-security.xml if you are using that).

    0 讨论(0)
  • 2020-12-04 12:16

    I had DependencyResolutionException in Ubuntu Linux when I've installed local artifacts via a shell script. The solution was to delete the local artifacts and install them again "manually" - calling mvn install:install-file via terminal.

    0 讨论(0)
提交回复
热议问题