2015-12-30 45 views
0

我有一個關於maven的問題。我只是用eclipse mars使用m2e,maven版本是3.3.3。它無法解決我的nexus私有存儲庫中的間接依賴關係。Maven不解決來自私人回購的間接依賴關係

例如,有3個項目:common-A,common-B,biz-X。

  • common-A和common-B都在nexus private repo中部署爲jar。
  • common-B取決於common-A。 biz-X取決於共同B。所以biz-X間接取決於普通的A.
  • biz-X項目成功下載了common-B。

問題是,biz-X無法下載common-A.jar。

任何人都可以幫助我!謝謝!


UPDATE1:

我有一些進步,這裏是M2E的堆棧跟蹤:

org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for (my groupId):common-B:jar:0.0.1-SNAPSHOT 
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:349) 
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:218) 
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.resolveCachedArtifactDescriptor(DefaultDependencyCollector.java:535) 
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.getArtifactDescriptorResult(DefaultDependencyCollector.java:519) 
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:409) 
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.processDependency(DefaultDependencyCollector.java:363) 
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.process(DefaultDependencyCollector.java:351) 
at org.eclipse.aether.internal.impl.DefaultDependencyCollector.collectDependencies(DefaultDependencyCollector.java:254) 
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.collectDependencies(DefaultRepositorySystem.java:316) 
at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:172) 
at org.apache.maven.project.DefaultProjectBuilder.resolveDependencies(DefaultProjectBuilder.java:215) 
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:188) 
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:119) 
at org.eclipse.m2e.core.internal.embedder.MavenImpl.readMavenProject(MavenImpl.java:636) 
at org.eclipse.m2e.core.internal.project.registry.DefaultMavenDependencyResolver.resolveProjectDependencies(DefaultMavenDependencyResolver.java:63) 
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refreshPhase2(ProjectRegistryManager.java:529) 
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:491) 
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager$3.call(ProjectRegistryManager.java:1) 
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) 
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151) 
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:495) 
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:350) 
at org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.refresh(ProjectRegistryManager.java:297) 
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:398) 
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:345) 
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:1) 
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176) 
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151) 
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99) 
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1351) 
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:342) 
at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:77) 
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39) 
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)Caused by: org.apache.maven.model.resolution.UnresolvableModelException: Could not find artifact (my groupId):root:pom:0.0.1-SNAPSHOT in public (http://192.168.1.35:8081/nexus/content/repositories/central) 
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:177) 
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:226) 
at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:978) 
at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:796) 
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:325) 
at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:340) 
... 33 moreCaused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact (my groupId):root:pom:0.0.1-SNAPSHOT in public (http://192.168.1.35:8081/nexus/content/repositories/central) 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444) 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246) 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223) 
at org.apache.maven.repository.internal.DefaultModelResolver.resolveModel(DefaultModelResolver.java:173) 
... 38 moreCaused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact (my groupId):root:pom:0.0.1-SNAPSHOT in public (http://192.168.1.35:8081/nexus/content/repositories/central) 
at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:893) 
at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:1) 
at io.takari.aether.connector.AetherRepositoryConnector$GetTask.flush(AetherRepositoryConnector.java:673) 
at io.takari.aether.connector.AetherRepositoryConnector.get(AetherRepositoryConnector.java:310) 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520) 
at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421) 
... 41 more 

看來,行家說,她無法理解的共同-B的POM文件。但是我發現有包括一個pom.xml在下載共B.jar,位置是:

/META-INF /行家/(一些包裝)/common-B/pom.xml

它實際上是我在項目common-B的根目錄中定義的pom。 但爲什麼maven不加載它? 或者如果這個pom文件不是maven需要的? 或者如果pom文件需要從私人回購下載?如果是這樣,我發現common-B-0.0.1-yyyyMMdd(可能是seq).pom在正確的nexus repo目錄中的jar文件的相同位置,maven不會加載它?是否因爲我將這個工件部署爲SNAPSHOT類型? 或者是否有一些我需要做的「mvn deploy」操作?

以上是線索。希望他們有用。


UPDATE2:

哦,我....我必須跟我開玩笑。我找到了原因。因爲我忘了部署一個root pom,所有常見的工件都會擴展它。現在問題解決了。感謝你們!

+0

什麼是依賴關係的範圍? –

+0

他們都是編譯 Oraple

回答

0

您需要兩個版本庫的URL,以及快照庫網址添加到pom.xml中(或)settings.xml中

請嘗試將兩個URL作爲鏈接指定:
Adding Snapshot Repo to pom.xml

+0

謝謝,但這不是我的問題,問題已解決。請參閱update2。 – Oraple