简体   繁体   English

脱机使用所有Maven存储库

[英]Work offline with all Maven repositories

I need to work offline using Maven , therefore, before going offline I should download all the project dependencies using Maven . 我需要使用Maven脱机工作,因此,在脱机之前,我应该使用Maven下载所有项目依赖项。

  1. In case I use ALL Maven repositories, how much space it would take? 如果我使用ALL Maven存储库,它将占用多少空间?

  2. Is there a simple way I can download all Maven dependencies known to mankind? 有什么简单的方法可以下载人类已知的所有Maven依赖项?

I want to stay offline for security reasons. 出于安全原因,我想保持离线状态。 And I'm not sure about the Maven dependencies that will be added in the process of development. 而且我不确定在开发过程中将添加的Maven依赖项。

As said above, downloading all possible Maven dependencies is no good choice. 如上所述,下载所有可能的Maven依赖项不是一个好选择。 MavenCentral probably consists of several TB, and if you try to download all of it, you may end up on the blacklist. MavenCentral可能包含几个TB,如果尝试下载所有TB,则最终可能会列入黑名单。

Our company network is also not directly connected to MavenCentral. 我们的公司网络也没有直接连接到MavenCentral。 Instead, we run our own Nexus and have a copy job that copies a requested and approved dependency (with all its transitive dependencies) to our company Nexus. 取而代之的是,我们运行自己的Nexus,并执行复制作业,将请求并批准的依赖项(及其所有传递性依赖项)复制到公司Nexus。

You can do the same, or use your local repository on your computer for this purpose. 您可以执行相同操作,或为此目的在计算机上使用本地存储库。

One other approach would be to create a dummy project on a computer connected to the internet, put every direct dependency in the pom of the dummy project and let Maven download everything you need. 另一种方法是在连接到互联网的计算机上创建一个虚拟项目,将每个直接依赖项放入该虚拟项目的pom中,然后让Maven下载所需的一切。 Then you can copy the repo from the dummy project to your real project. 然后,您可以将回购从虚拟项目复制到真实项目。

Of course, in both cases, the steps have to be executed every time you add a dependency. 当然,在两种情况下,每次添加依赖项时都必须执行步骤。

Before going offline try to find out the dependencies you need. 脱机之前,请尝试找出所需的依赖项。

Then do an update project on maven. 然后在Maven上执行一个更新项目。 It will do download all the dependencies for you. 它将为您下载所有依赖项。 And then you can remain offline as long as you don't need to add any other dependency. 然后,您无需添加任何其他依赖项就可以保持脱机状态。

You can use this command: 您可以使用以下命令:

mvn clean install -U

If you are using Eclipse for your project, then right click on the project -> Select Maven -> Update Project 如果您将Eclipse用于项目,则右键单击该项目->选择Maven->更新项目

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

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