問題:我在使用org.apache.httpcomponents:httpclient:4.5:jar時,maven老是從個人私服下載失敗。 個人本地倉庫路徑配置在這裏: java
操做1:解決這個問題僅僅在eclipse裏工程右鍵Maven -> Update Project是不夠的,最好在Run -> Maven build裏配置Goals爲clean compile -X或者勾選Debug Output(見下圖),這樣在更新依賴時就會顯示更詳細的解析下載依賴過程。apache
思考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***任務要下載遠程倉庫的索引,而網絡很差時(一般遠程倉庫在國外,網絡很差是常有的),任務會執行失敗。以下:app
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文件,而後拷貝到私服倉庫的路徑裏。個人路徑以下:eclipse
而後Update Index。接着刪除本地倉庫commons-logging:commons-logging:1.2下的全部文件,從新執行Maven build。jvm
Expire Repository Caches:socket
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:maven
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:ide
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將首先下載遠程索引(僅限代理倉庫),而後掃描本地存儲,進而索引新的構件。最後,索引將隨倉庫發佈。一般,不須要執行該任務。除非常常有構件被直接部署到本地存儲。