Development Tip

강제 메이븐 업데이트

yourdevel 2020. 9. 30. 11:32
반응형

강제 메이븐 업데이트


내 작업 프로젝트를 다른 컴퓨터로 가져 와서 종속성을 다운로드하기 시작했습니다.

그동안 인터넷 연결이 끊어진 것 같습니다. 이제 얻을 수 있습니다.

만화에 대한 빌드 오류; org.apache.maven.lifecycle.LifecycleExecutionException : comicsTest 프로젝트에서 목표를 실행하지 못했습니다. comicsTest : comicsTest : war : 0.0.1-SNAPSHOT 프로젝트에 대한 종속성을 해결할 수 없습니다. 다음 아티팩트를 해결할 수 없습니다. org.springframework : spring- context : jar : 3.0.5.RELEASE, org.hibernate : hibernate-entitymanager : jar : 3.6.0.Final, org.hibernate : hibernate-core : jar : 3.6.0.Final, org.hibernate : hibernate-commons- annotations : jar : 3.2.0.Final, org.aspectj : aspectjweaver : jar : 1.6.8, commons-lang : commons-lang : jar : 2.5,

mysql : mysql-connector-java : jar : 5.1.13 : http://repo1.maven.org/maven2 에서 org.springframework : spring-context : jar : 3.0.5.RELEASE 전송 실패가 로컬 저장소에 캐시되었습니다. , 중앙 업데이트 간격이 경과하거나 업데이트가 강제 실행될 때까지 해결이 다시 시도되지 않습니다.

원래 오류 : 중앙에서 아티팩트 org.springframework : spring-context : jar : 3.0.5.RELEASE를 전송할 수 없습니다 ( http://repo1.maven.org/maven2 ) : 60000 이후 수신 된 응답 없음

그리고 maven을 강제로 업데이트하는 방법을 모릅니다.


mvn clean install -U

-U스냅 샷 종속성 의 강제 업데이트를 의미합니다 . 릴리스 종속성은이 방법으로 업데이트 할 수 없습니다.


-U 모든 종속성의 업데이트를 강제하는 것 같습니다.

정리하지 않고 단일 종속성을 업데이트하거나 -U로컬 저장소에서 제거한 다음 빌드 할 수 있습니다.

업데이트하는 경우 아래 예 slf4j-api 1.7.1-SNAPSHOT:

rm -rf ~/.m2/repository/org/slf4j/slf4j-api/1.7.1-SNAPSHOT
mvn compile

로컬 리포지토리가 스냅 샷 ( -U--update-snapshots업데이트 스냅 샷 만) 달리 릴리스 jar에 대해 어떻게 든 엉망이 된 경우 다음을 사용하여 로컬 리포지토리 를 제거 할 수 있습니다.

 mvn dependency:purge-local-repository

그런 다음 청소하고 다시 설치하고 싶을 것입니다.

 mvn dependency:purge-local-repository clean install

https://maven.apache.org/plugins/maven-dependency-plugin/examples/purging-local-repository.html 에서 더 많은 정보를 확인할 수 있습니다.


여기에있는 모든 답변이 저에게 효과가 없었습니다. 망치 방법을 사용했습니다.

find ~/.m2/ -name "*.lastUpdated" | xargs rm

문제가 해결되었습니다. :-)


에서 효과적으로 수행 할 수 있습니다 Eclipse IDE. 물론 당신이 그것을 사용한다면.

Project_Name->Maven->Update Project Configuration->Force Update of Snapshots/Releases

누군가가 프로젝트의 스냅 샷 종속성 만 업데이트하고 아티팩트를 설치하고 싶지 않은 경우 :

mvn dependency:resolve -U

IDE에서 종속성을 다시 가져 오는 것을 잊지 마십시오. IDEA에서 pom 파일을 마우스 오른쪽 버튼으로 클릭하고 Maven-> Reimport를 선택해야합니다.


로컬 저장소에 무엇이 있는지 확실하지 않은 경우 다음 옵션을 사용하여 빌드를 시작하는 것이 좋습니다.

-Dmaven.repo.local=localrepo

이렇게하면 클린 룸 환경에서 구축 할 수 있습니다.


제 경우에는 처음으로 다음과 같이했습니다.

mvn clean install -U

그래도 동일한 오류가 표시되고 프로젝트를 닫고 다시 열었습니다. 마침내 일했습니다.


Eclipse IDE사용하는 경우 다음을 수행하십시오.

  • 프로젝트를 선택하십시오.
  • Alt + F5를 누르면 Update Maven Project 창이 나타납니다.

  • 확인-스냅 샷 / 릴리스 강제 업데이트를 클릭하고 확인을 클릭합니다.

Intellij IDE를 사용하는 경우

  • 설정 / Maven으로 이동
  • 항상 스냅 샷 업데이트를 선택하십시오.

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.


This is one of the most annoying things about Maven. For me the following happens: If I add a dependency requesting more dependencies and more and more but have a slow connection, it seams to stop while downloading and timing out. While timing out all dependencies not yet fetched are marked with place holders in the .m2 cache and Maven will not (never) pick it up unless I remove the place holder entry from the cache (as other stated) by removing it.

So as far as I see it, Maven or more precise the Eclipse Maven plugin has a bug regarding this. Someone should report this.


You need to check your settings.xml file under <maven_home>/conf directory.


I've got the same error with android-maps-utils dependency. Using aar type package in dependency section solve my problem. By default type is jar so It might be checked what type of dependency in repository is downloaded.


For fixing this issue from Eclipse:

1) Add below dependency in Maven pom.xml and save the pom.xml file.

<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
    <groupId>com.thoughtworks.xstream</groupId>
    <artifactId>xstream</artifactId>
    <version>1.3.1</version>
</dependency>

2) Go to project >> Maven >> Update Project

select the project and click OK.

3) Optional step, if it's not resolved till step 2 then do below step after doing step-1

Go to project >> Maven >> Update Project >> check in the checkbox 'Force Update of Snapshots/Releases'

select the project and click OK.


It's important to add that the main difference of running mvn with -U and without -U is that -U will override your local SNAPSHOT jars with remote SNAPSHOT jars.

Local SNAPSHOT jars created from local mvn install in cases where you have other modules of your proj that generate jars.


-U is used to force update maven Repo. Use

mvn -U clean install

I tried all the answers here but nothing seemed to work. Restarted my computer first then ran mvn clean install -U. That solved my problem.


What maven does is, it downloads all your project's dependencies into your local repo (.m2 folder). Because of the internet causing issues with your local repo, you project is facing problems. I am not sure if this will surely help you or not but you can try deleting all the files within the repository folder inside the .m2 folder. Since there would be nothing in the local repo, maven would be forced to download the dependencies again, thus forcing an update. Generally, the .m2 folder is located at c:users:[username]:.m2


I had this problem for a different reason. I went to the maven repository https://mvnrepository.com looking for the latest version of spring core, which at the time was 5.0.0.M3/ The repository showed me this entry for my pom.xml:

<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.0.0.M3</version>
</dependency>

Naive fool that I am, I assumed that the comment was telling me that the jar is located in the default repository.

However, after a lot of head-banging, I saw a note just below the xml saying "Note: this artifact it located at Alfresco Public repository (https://artifacts.alfresco.com/nexus/content/repositories/public/)"

So the comment in the XML is completely misleading. The jar is located in another archive, which was why Maven couldn't find it!


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

mvn --update-snapshots clean install

I had the same error and running mvn install -U and then running mvn install worked for me.


I ran into this recently and running the following fixed all the problems

mvn -fae install

mvn clean install -U doesn't work. However mvn -U clean followed by mvn clean install does.

참고URL : https://stackoverflow.com/questions/4701532/force-maven-update

반응형