Nexus下载构件失败
問題:我在使用org.apache.httpcomponents:httpclient:4.5:jar時,maven總是從我的私服下載失敗。
我的本地倉庫路徑配置在這里:
操作1:解決這個問題僅僅在eclipse里工程右鍵Maven -> Update Project是不夠的,最好在Run -> Maven build里配置Goals為clean compile -X或者勾選Debug Output,這樣在更新依賴時就會顯示更詳細的解析下載依賴過程。
思考1:但是下載構件并不總是成功。我下載org.apache.httpcomponents:httpclient:4.5:jar失敗,其實并不僅僅于此。該構件會依賴commons-logging-1.2.jar和commons-codec-1.9.jar。這兩個構件同樣下載失敗。所以要解決httpclient-4.5.jar的問題,要先下載commons-logging-1.2.jar和commons-codec-1.9.jar構件。
操作2:以commons-logging-1.2.jar為例,首先查看Nexus私服本地是否已下載構件:Repositories -> Central -> Browse Storage,commons-logging:commons-logging:1.2下面只有commons-logging.pom文件。這時在commons-logging上右鍵 > Expire Cache,然后Delete,然后Update Index(這三個操作我在很多博客上看到的,并不十分確定有效,但確實成功過)。接著刪除Maven的本地倉庫(不是私服的倉庫)下commons-logging:commons-logging:1.2的所有文件。重新Maven build。最后查看本地倉庫是否下載成功commons-logging-1.2.jar構件。
思考2:按照上步的操作,結果并不總是成功。某種情況下(甚至是多種情況下),仍會多次重現問題。不過要確認一個事情,對于代理倉庫,Update Index任務要下載遠程倉庫的索引,而網絡不好時(通常遠程倉庫在國外,網絡不好是常有的),任務會執行失敗。如下:
jvm 2 | 2015-08-12 10:22:07 INFO [pool-1-thread-1] - org.sonatype.nexus.tasks.ExpireCacheTask - Scheduled task (ExpireCacheTask) started :: Expiring caches for repository Central from path /commons-logging/commons-logging/1.2/ and below. jvm 2 | 2015-08-12 10:22:08 INFO [pool-1-thread-1] - org.sonatype.nexus.tasks.ExpireCacheTask - Scheduled task (ExpireCacheTask) finished :: Expiring caches for repository Central from path /commons-logging/commons-logging/1.2/ and below. (started 2015-08-12T10:22:07+08:00, runtime 0:00:00.625) jvm 2 | 2015-08-12 10:22:10 INFO [pool-1-thread-1] - org.sonatype.nexus.tasks.UpdateIndexTask - Scheduled task (UpdateIndexTask) started :: Updating repository index "Central" from path /commons-logging/commons-logging/1.2/ and below. jvm 2 | 2015-08-12 10:22:10 INFO [pool-1-thread-1] - org.sonatype.nexus.index.DefaultIndexerManager - Trying to get remote index for repository "Central" [id=central] jvm 2 | 2015-08-12 10:23:13 WARN [pool-1-thread-1] - org.sonatype.nexus.index.DefaultIndexerManager - Cannot fetch remote index for repository "Central" [id=central] jvm 2 | java.net.SocketTimeoutException: Read timed out jvm 2 | at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.6.0_05] jvm 2 | at java.net.SocketInputStream.read(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.io.BufferedInputStream.read1(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.io.BufferedInputStream.read(Unknown Source) ~[na:1.6.0_05] jvm 2 | at org.apache.commons.httpclient.ContentLengthInputStream.read(Unknown Source) ~[commons-httpclient-3.1.SONATYPE.jar:3.1] jvm 2 | at java.io.FilterInputStream.read(Unknown Source) ~[na:1.6.0_05] jvm 2 | at org.apache.commons.httpclient.AutoCloseInputStream.read(Unknown Source) ~[commons-httpclient-3.1.SONATYPE.jar:3.1] jvm 2 | at org.sonatype.nexus.util.WrappingInputStream.read(WrappingInputStream.java:59) ~[nexus-utils-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.proxy.storage.remote.commonshttpclient.HttpClientInputStream.read(HttpClientInputStream.java:95) ~[nexus-proxy-2.0.4-1.jar:na] jvm 2 | at java.io.BufferedInputStream.read1(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.io.BufferedInputStream.read(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.io.BufferedInputStream.fill(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.io.BufferedInputStream.read1(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.io.BufferedInputStream.read(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.util.zip.InflaterInputStream.fill(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.util.zip.InflaterInputStream.read(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.util.zip.GZIPInputStream.read(Unknown Source) ~[na:1.6.0_05] jvm 2 | at java.io.DataInputStream.readFully(Unknown Source) ~[na:1.6.0_05] jvm 2 | at org.apache.maven.index.updater.IndexDataReader.readUTF(IndexDataReader.java:193) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.IndexDataReader.readField(IndexDataReader.java:162) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.IndexDataReader.readDocument(IndexDataReader.java:137) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.IndexDataReader.readIndex(IndexDataReader.java:90) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.DefaultIndexUpdater.unpackIndexData(DefaultIndexUpdater.java:509) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.DefaultIndexUpdater.loadIndexDirectory(DefaultIndexUpdater.java:197) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.DefaultIndexUpdater.access$300(DefaultIndexUpdater.java:76) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.DefaultIndexUpdater$LuceneIndexAdaptor.addIndexChunk(DefaultIndexUpdater.java:636) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:829) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:157) ~[indexer-core-4.1.3-SONATYPE.jar:4.1.3-SONATYPE] jvm 2 | at org.sonatype.nexus.index.DefaultIndexerManager.updateRemoteIndex(DefaultIndexerManager.java:1131) [nexus-indexer-lucene-plugin-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.index.DefaultIndexerManager.downloadRepositoryIndex(DefaultIndexerManager.java:1016) [nexus-indexer-lucene-plugin-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.index.DefaultIndexerManager.reindexRepository(DefaultIndexerManager.java:890) [nexus-indexer-lucene-plugin-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.index.DefaultIndexerManager.reindexRepository(DefaultIndexerManager.java:838) [nexus-indexer-lucene-plugin-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.index.DefaultIndexerManager.reindexRepository(DefaultIndexerManager.java:812) [nexus-indexer-lucene-plugin-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.tasks.ReindexTaskHandlerLegacy.reindexRepository(ReindexTaskHandlerLegacy.java:54) [nexus-indexer-lucene-plugin-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.tasks.AbstractIndexerTask.doRun(AbstractIndexerTask.java:69) [nexus-indexer-lucene-plugin-2.0.4-1.jar:na] jvm 2 | at org.sonatype.nexus.scheduling.AbstractNexusTask.call(AbstractNexusTask.java:152) [nexus-app-2.0.4-1.jar:na] jvm 2 | at org.sonatype.scheduling.DefaultScheduledTask.call(DefaultScheduledTask.java:459) [plexus-task-scheduler-1.6.0.jar:na] jvm 2 | at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) [na:1.6.0_05] jvm 2 | at java.util.concurrent.FutureTask.run(Unknown Source) [na:1.6.0_05] jvm 2 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.6.0_05] jvm 2 | at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.6.0_05] jvm 2 | at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [na:1.6.0_05] jvm 2 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.6.0_05] jvm 2 | at java.lang.Thread.run(Unknown Source) [na:1.6.0_05]操作3:如果上步不能解決你的問題,只能用笨法了。在私服上,Repositories -> Central -> Browse Storage,commons-logging:commons-logging:1.2右鍵View Remote,直接下載jar和pom文件,然后拷貝到私服倉庫的路徑里。我的路徑如下:
然后Update Index。接著刪除本地倉庫commons-logging:commons-logging:1.2下的所有文件,重新執行Maven build。
- 名詞解釋
Expire Repository Caches:
Repositories have several caches to improve performance. This task expires the caches causing Nexus to recheck the remote repository for a proxy repository or the file system for a hosted repository. You can configure the repository or group to be affected with the task setting Repository/-Group. Alternatively you can provide a Repository Path to configure the content that should be expired. 倉庫的緩存是為了提升性能。 使緩存失效的任務會引發Nexus重新檢查代理倉庫的遠程倉庫或者宿主倉庫的本地文件系統。 你可以通過配置使任務作用于倉庫或倉庫組,甚至于一個倉庫的路徑。Repair Repositories Index:
In certain cases it might be required to remove the internal index as well as the published ones of a repository. This task does that and then rebuilds the internal index by first trying to download remote indexes (if a proxy repository), then scanning the local storage and updating the internal index accordingly. Lastly, the index is published for the repository as well. There should be no need to schedule this task. But when upgrading Nexus, the upgrade instructions may sometimes include a manual step of executing this task. 有些情況下,我們需要移除內部索引,還有某個倉庫里已經發布的索引。 該任務做以上事情,接著會先嘗試下載遠程索引(對于代理倉庫而言)進而重建內部索引,然后掃描本地倉庫同時相應地更新內部索引。 最后,索引就隨倉庫發布了。 通常是沒必要執行該任務的。 但在升級Nexus時,升級指南有時會包含手動執行該任務的方法。Update Repositories Index:
If files are deployed directly to a repository’s local storage (not deployed through Nexus), you will need to instruct Nexus to update its index. When executing this task, Nexus will update its index by first downloading remote indexes (if a proxy repository) and then scan the local storage to index the new files. Lastly, the index is published for the repository as well. Normally, there should be no need to schedule this task. One possible except would be if files are deployed directly to the local storage regularly. 如果把構件直接部署到私服的本地倉庫(而非通過Nexus部署),你需要指導Nexus更新索引。 更新索引時,Nexus將首先下載遠程索引(僅限代理倉庫),然后掃描本地存儲,進而索引新的構件。 最后,索引將隨倉庫發布。 通常,不需要執行該任務。除非經常有構件被直接部署到本地存儲。總結
以上是生活随笔為你收集整理的Nexus下载构件失败的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2139=数据结构实验之图论五:从起始点
- 下一篇: 卡方检验python程序_Python从