简体   繁体   English

Maven内部存储库,这真的很难吗?

[英]Maven Internal Repository, Is it Really This Hard?

I have several projects which use Maven and I would like to run an internal repository on my work network. 我有几个使用Maven的项目,我想在我的工作网络上运行一个内部存储库。 I have several libraries which are from third parties and cannot be released into the wild, as well as a few libraries of our own which need to be available within the network (including to our TeamCity CI Server) but cannot be deployed outside the network. 我有几个来自第三方的库,不能发布到野外,还有一些我们自己的库需要在网络中可用(包括我们的TeamCity CI服务器),但不能在网络外部署。 After a bit of research, I found three main recommendations on how to accomplish this: Archiva, Artifactory, and Nexus. 经过一些研究,我发现了三个关于如何实现这一目标的主要建议:Archiva,Artifactory和Nexus。 I have tried each, and have failed to achieve a successful build of any of my projects using the internal repositories created by any of them. 我已经尝试了每个,并且未能使用其中任何一个创建的内部存储库成功构建我的任何项目。

This leads me to believe that I am misunderstanding something or doing something wrong. 这让我相信我误解了某些事情或做错了什么。 Does anyone know of a tutorial that will walk me through setting up and internal Maven repository and integrate it with my project? 有没有人知道一个教程,它将引导我完成设置和内部Maven存储库并将其与我的项目集成?

I have only worked with Nexus, but I found it very easy to install: 我只使用过Nexus,但我发现它很容易安装:

  1. Go to http://www.sonatype.org/nexus/go to download the OSS version 访问http://www.sonatype.org/nexus/go下载OSS版本
  2. Get the 'WAR' distribution 获取'WAR'分发
  3. Install the servlet in my installation of Tomcat, via the Web Application Manager 通过Web应用程序管理器在我的Tomcat安装中安装servlet

At that point, I can visit http://myserver:8080/nexus to see everything working. 那时,我可以访问http://myserver:8080/nexus来查看一切正常。

For a superficial setup, I add the default password to my settings.xml : 对于表面设置,我将默认密码添加到我的settings.xml

    <servers>
            <server>
                    <id>my-snapshots</id>
                    <username>admin</username>
                    <password>admin123</password>
            </server>
            <server>
                    <id>my-releases</id>
                    <username>admin</username>
                    <password>admin123</password>
            </server>
    </servers>

and in my POM file: 在我的POM文件中:

    <distributionManagement>
            <snapshotRepository>
                    <id>my-snapshots</id>
                    <name>My internal repository</name>
                    <url>http://myserver:8080/nexus/content/repositories/snapshots</url>
            </snapshotRepository>
            <repository>
                    <id>my-releases</id>
                    <name>My internal repository</name>
                    <url>http://myserver:8080/nexus/content/repositories/releases</url>
            </repository>
    </distributionManagement>

To go beyond this, the learning curve jumps up quite a bit, but I found Sonatype's online books to be pretty good. 为了超越这个,学习曲线跳了很多,但我发现Sonatype的在线书籍非常好。 Repository Management with Nexus is the one for understanding what you can do with the repository server. 使用Nexus进行存储库管理是了解如何使用存储库服务器执行的操作。 The only thing I found tricky is that some of the info applies only to their commercial software and they don't work too hard to advertise the difference. 我发现唯一棘手的问题是,有些信息仅适用于他们的商业软件,而且他们并不太努力地宣传差异。

Repository managers like Archiva and Nexus are more than just an internal repository. 像Archiva和Nexus这样的知识库管理器不仅仅是一个内部存储库。 They serve as proxies that obviate reaching out to Maven central or other external repository. 它们作为代理,可以避免与Maven中心或其他外部存储库联系。

For just an internal repository all you need is a network or HTTP accessible location that has the structure of a Maven repository. 对于内部存储库,您只需要一个具有Maven存储库结构的网络或HTTP可访问位置。 Then you refer to it as another repository in your settings file . 然后,您将其称为设置文件中的另一个存储库

<repository>
  <id>my-internal-repo</id>
  <url>http://myrepo.mycompany.com/</url>
</repository>

See more in Maven's documentation at http://maven.apache.org/guides/introduction/introduction-to-repositories.html . 有关Maven文档的更多信息,请访问http://maven.apache.org/guides/introduction/introduction-to-repositories.html

I would suggest to use the Nexus evaluation guide (latest available version is 2.13 now) that comes with the Nexus Pro Installer , but also works with Nexus Open Source for the simple use cases of proxying and deploying components. 我建议使用Nexus评估指南 (最新版本现在是2.13 ),它与Nexus Pro安装程序一起使用 ,但也可以与Nexus Open Source一起使用,用于代理和部署组件的简单用例。

The examples are also available on github and include setups for Maven, Ant/Ivy and Gradle. 这些示例也可以在github上获得 ,包括Maven,Ant / Ivy和Gradle的设置。 Once you have a look at the examples and read the guide you will be able to set up your projects in the same way easily. 一旦您查看了示例并阅读了指南,您就可以轻松地以相同的方式设置项目。

And of course if there is any problems you can always ask on the mailing list or chat with the developers on hipchat 当然,如果有任何问题,您可以随时在邮件列表上询问或与开发人员聊聊

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM