2016-11-16 27 views
0

我已经建立了一个nexus服务器,之后我有意见简单地在这个nexus服务器上部署一个artefact。因此,我创建了这个POM一个简单的Java项目:在nexus服务器上部署Artefact - 错误依赖关系无法解决

<project xmlns="..."> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>MyProject</groupId> 
    <artifactId>MyProject</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <build> 
    <sourceDirectory>src</sourceDirectory> 
    <plugins> 
     <plugin> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>3.3</version> 
     <configuration> 
      <source>1.8</source> 
      <target>1.8</target> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

我的设置文件看起来像这样:

<?xml version="1.0" encoding="UTF-8"?> 
<settings ...> 
    <pluginGroups> 
    </pluginGroups> 

    <proxies> 
    </proxies> 

    <servers> 
    </servers> 

    <mirrors> 
    <mirror>  
     <id>nexus</id> 
     <name>Nexus Public Mirror</name> 
     <mirrorOf>central</mirrorOf> 
     <url>http://it-nexus.domain:8081/nexus/content/groups/public</url> 
    </mirror> 
    </mirrors> 

    <profiles> 
    <profile> 
    <id>nexus</id> 
    <repositories> 
     <repository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </repository> 
     </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </pluginRepository> 
     </pluginRepositories> 
    </profile> 
    </profiles> 

    <activeProfiles> 
    <activeProfile>nexus</activeProfile> 
    </activeProfiles> 

</settings> 

然后我试图与部署我的假象:

mvn deploy

和我得到这个错误:

[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-resources-plugin 
:jar:2.6 in http://it-nexus.domain:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of 
nexus has elapsed or updates are forced -> [Help 1] 

其实我不知道我在做什么错!

回答

0

你有一些错误的东西(好吧,一切都是如此)。

首先,您可以从server.xml文件中删除profiles及其下的所有内容以及activeProfiles。接下来,您需要添加一个servers条目,其中包含一个服务器,其中包含id,'nexus'(假设您上传到您用于镜像中心的同一个nexus实例)以及某种用户名和密码。

然后你必须在你的pom中有一个distributionManagement部分,引用你在settings.xml文件中指定的server,并配置maven-deploy插件。相关文档可以在here找到。您还需要一个scm部分。

您所谈论的实际错误可能是因为您的nexus服务器实际上未配置为代理/镜像central。哦,你应该使用*作为mirrorOf的参数。

相关问题