2016-03-09 28 views
0

在我的Nexus中,我自己的项目位于托管库“Snapshots”下。我必须将此存储库分配给“公共存储库”;否则,我不能用mvn编译我自己的项目。这将是错误消息:不想让我自己的Nexus上的工件公开

[ERROR] Failed to execute goal on project bword: Could not resolve dependencies for project com.bbword.core:bword:war:0.0.1-SNAPSHOT: Could not find artifact com.bbword.core:tts-app:jar:0.0.1-SNAPSHOT in nexus (http://www.bbword.com:8081/nexus/content/groups/public) -> [Help 1] 
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 
[ERROR] Re-run Maven using the -X switch to enable full debug logging. 

当然,我不希望在互联网上的公开信息库我自己的项目。我可能会错哪个配置?

这是我的settings.xml:

<?xml version="1.0"?> 
<settings> 
    <mirrors> 
    <mirror> 
     <id>nexus</id> 
     <mirrorOf>*</mirrorOf> 
     <url>http://www.bbword.com:8081/nexus/content/groups/public</url> 
    </mirror> 
    </mirrors> 
    <servers> 
    <server> 
     <id>nexus</id> 
     <username>admin</username> 
     <password>bbword</password> 
    </server> 
    </servers> 
    <profiles> 
    <profile> 
     <id>nexus</id> 
     <!--Enable snapshots for the built in central repo to direct --> 
     <!--all requests to nexus via the mirror --> 
     <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> 
    <!--make the profile active all the time --> 
    <activeProfile>nexus</activeProfile> 
    </activeProfiles> 
</settings> 

编辑:附图片为更好的说明。
enter image description here

我的项目是在“快照”下。

修改:新附件了解详情。

enter image description here

+0

所以使用本地的Nexus存储这样的事情或做内的Nexus一个单独的组,其不是公众可以访问的。 – khmarbaise

+0

@khmarbaise,请查看图片了解当前状态。你的意思是什么“独立小组”,我该怎么做? “快照”目前不在“公共存储库”之下。 – user697911

+0

制作一个新的存储库组请参见:https://books.sonatype.com/nexus-book/reference/config-sect-new-repo.html并将该快照添加到该组中... – khmarbaise

回答

0

你有不同的地方能够控制的是公众从互联网访问:

  • 你可以告诉纽带就是仓库是私有,但Maven将不能够使用它
  • 你可以告诉nexus知识库是公开的,并隐藏你自己的网络连接。

当你配置你自己的本地连结时,什么是公有是什么是公共的是nexus在它自己的服务器上显示的。这并不意味着它会自动上传到maven central或任何其他公共连接服务器。

但如果这是你自己的关系,你没有理由让服务器本身从互联网和防火墙(或您的ISP路由器)访问应该简单地不允许外部调用到这里。这对于您自己的项目来说不会在互联网的公共存储库下面存在

+0

如何不让外部访问我自己的联系? – user697911

+0

很难说不知道主机连接的机器如何连接到互联网。您不会在企业网络,家庭或基础架构即服务云虚拟机中使用相同的解决方案... –

0

这样做至少有两种方法。两者都需要管理员权限。

可应用的方法:您创建一个新的托管存储库并使用凭据进行保护这里有一篇文章描述如何:(http://minibiti.blogspot.ca/2012/03/private-repositories-in-sonatype-nexus.html) 您甚至可以禁用该存储库的用户界面。

组网方式: 您需要访问您的关系,但是从互联网隔离开来。当然,如果你这样做,不要代理中央存储库,也不要将其用作镜像。

此外,第一个解决方案的帖子建议您以纯文本形式输入密码。我不喜欢这个。看看这个职位行家加密https://maven.apache.org/guides/mini/guide-encryption.html

编辑: 这里如何增加凭证的Settings.XML

<repository> 
        <id>ID</id> 
        <name>name</name> 
        <url>URL</url> 
        <snapshots> 
         <enabled>false</enabled> 
        </snapshots> 
        <releases> 
         <enabled>true</enabled> 
        </releases> 
       </repository> 

<server> 
      <id>ID</id> 
      <username>USER</username> 
      <password>PASSWORD</password> 
     </server> 
+0

我遵循第一个解决方案,将匿名限制为公共存储库,并将其自己的项目放在非 - 公共(非私有)托管的存储库。不过,我仍然可以从互联网浏览它:http://www.bombword.com:8081/nexus/content/repositories/snapshots/com/bombword/core/bword。为什么是这样? – user697911

+0

链接返回给我一个401拒绝访问,也http://www.bombword.com:8081/nexus/#welcome,我看不到任何存储库 – drgn

+0

这是真的。我注销并且无需首先登录就无法再访问它。但另一个问题是我无法通过maven访问我自己的项目。使用mvn编译,我收到了这个错误:[错误]无法执行项目目标bword:无法解析项目的依赖关系com.bombword.core:bword:war:0.0.1-SNAPSHOT:T – user697911