How to force maven update?

后端 未结 25 1975
失恋的感觉
失恋的感觉 2020-11-22 03:18

I imported my already working project on another computer and it started to download dependencies.

Apparently my internet connection crashed and now I get the foll

相关标签:
25条回答
  • 2020-11-22 04:03

    Previous versions of maven did not force the check for missing releases when used -U with mvn clean install, only the snapshots, though newer version supports this.

    For someone still struggling with previous version, following can be helpful-

    On Windows:

    cd %userprofile%\.m2\repository
    for /r %i in (*.lastUpdated) do del %i
    

    On Linux:

    find ~/.m2  -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;
    

    Whenever maven can't download dependencies for any reason (connectivity/not exists etc), it will add the ".error=Could not transfer artifact" in dependency-name.lastUpdate file in respective folder under $home/.m2 directory. Removing these files will force maven to try fetching the dependencies again.

    0 讨论(0)
  • 2020-11-22 04:05

    If your local repository is somehow mucked up for release jars as opposed to snapshots (-U and --update-snapshots only update snapshots), you can purge the local repo using the following:

     mvn dependency:purge-local-repository
    

    You probably then want to clean and install again:

     mvn dependency:purge-local-repository clean install
    

    Lots more info available at https://maven.apache.org/plugins/maven-dependency-plugin/examples/purging-local-repository.html

    0 讨论(0)
  • 2020-11-22 04:09

    You can do effectively from Eclipse IDE. Of course if you are using it.

    Project_Name->Maven->Update Project Configuration->Force Update of Snapshots/Releases
    
    0 讨论(0)
  • I used the IntelliJ IDE and I had a similar problem and to solve I clicked in "Generate Sources and Update Folders for All Projects" in Maven tab.

    0 讨论(0)
  • 2020-11-22 04:09

    I've got the error in an other context. So my solution might be useful to others who stumple upon the question:

    The problem: I've copied the local repository to another computer, which has no connection to a special repository. So maven tried to check the artifacts against the invalid repository.

    My solution: Remove the _maven.repositories files.

    0 讨论(0)
  • 2020-11-22 04:09

    We can force to get latest update of release and snapshot repository with below command :

    mvn --update-snapshots clean install
    
    0 讨论(0)
提交回复
热议问题