AdSense

網頁

2018/9/3

使用Spring Tool Suite(STS)建立spring boot專案時maven下載jar出現問題

今天第一次使用Spring Tool Suite(STS)建立spring boot專案時,專案的maven在下載jar的過程中出現問題如下。

ArtifactTransferException: Failure to transfer org.sonatype.plexus:plexus-build-api:jar:0.0.7 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.sonatype.plexus:plexus-build-api:jar:0.0.7 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled. java.lang.reflect.InvocationTargetException

問題出現後專案目錄就出現一堆紅色叉叉,結構也很奇怪。

解決的辦法是在專案上按右鍵 -> Maven -> Update Project... -> 勾選[Force Update of Snapshots/Releases](其他選項保持預設)。設定完後按OK確定,接著maven就會重新下載,待maven執行完後專案就正常了。

上面的動作應該同等於maven指令mvn clean install -U-U就是強制從remote repository更新。

pom.xml有錯誤如下。

Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.21.0 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.21.0 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled. pom.xml /demo line 1 Maven Configuration Problem

解決方法是在專案上按右鍵 -> Run As -> Maven clean,接著在專案上按右鍵 -> Run As -> Maven intall即解決。


參考:

沒有留言:

AdSense