Maven:如何以离线模式安装插件 [英] Maven: How to install a plugin in offline mode
问题描述
我坐在防火墙后面,因此maven无法连接到中央存储库(错误消息在下面给出).
I'm sitting behind a firewall and therefore maven can't connect to central repositories (error message is given below).
但是,我可以通过HTTP连接到互联网.
However, I can connect to the internet via HTTP.
如何在离线模式下安装Maven插件(例如原型)(即在浏览器中下载一些文件,然后通过执行一些命令来安装该插件)?
How can I install a maven plugin (e. g. archetype) in offline mode (i. e. download some file in a browser and then install the plugin by executing some commands) ?
预先感谢
Dmitri
P. S .:这是错误消息:
P. S.: Here is the error message:
E:\>mvn archetype:generate -DarchetypeGroupId=com.vaadin
-DarchetypeArtifactId=vaadin-archetype-clean -DarchetypeVersion=LATEST -DgroupI
d=at.swdev -DartifactId=pcc -Dversion=1.0 -Dpackaging=war
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[WARNING] repository metadata for: 'org.apache.maven.plugins' could not be retri
eved from repository: central due to an error: Error transferring file: Connecti
on refused: connect
[INFO] Repository 'central' will be blacklisted
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exi
st or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Thu Jul 22 15:17:00 CEST 2010
[INFO] Final Memory: 1M/15M
[INFO] ------------------------------------------------------------------------
推荐答案
我坐在防火墙后面,因此maven无法连接到中央存储库(错误消息在下面给出).但是,我可以通过HTTP连接到Internet.
I'm sitting behind a firewall and therefore maven can't connect to central repositories (error message is given below). However, I can connect to the Internet via HTTP.
也许您应该澄清一点,因为Maven也使用HTTP.如果通过某种代理进行连接,则可以通过在~/.m2/settings.xml
中声明代理来配置Maven进行连接.请参见配置代理.
Maybe you should clarify a bit because Maven uses HTTP as well. If you connect through some kind of proxy, you CAN configure Maven to do so by declaring the proxy in your ~/.m2/settings.xml
. See Configuring a proxy.
如何在离线模式下安装Maven插件(例如原型)(即在浏览器中下载一些文件,然后通过执行一些命令来安装该插件)?
How can I install a maven plugin (e. g. archetype) in offline mode (i. e. download some file in a browser and then install the plugin by executing some commands)?
您可以使用install:install-file
目标在本地存储库中安装任何jar(请参见用法页).但这只是故事的一小部分,您还需要安装插件的依赖项.然后是依赖关系的依赖关系.这将很快成为一个真正的噩梦和难以处理的任务(Maven正是试图解决该任务).因此:
You can install any jar in your local repository using the install:install-file
goal (see the Usage page). But this is only a small part of the story, you'll need to install dependencies of the plugin too. And then dependencies of dependencies. This will very quickly become a real nightmare and unmanageable task (that Maven precisely tries to solve). So either:
- 将Maven配置为可以访问Internet〜或〜
- 在专用计算机上设置公司存储库(例如 Nexus ),并与管理员一起查看如何允许它以访问Internet)并配置您的Maven客户端以使用它〜或〜
- 将预先填充的"本地存储库从现有计算机复制到您的计算机并脱机运行maven(这意味着所有限制)〜或〜
- 不要使用Maven
- Configure Maven to access Internet if this is possible ~or~
- Setup a corporate repository (like Nexus) on a dedicated machine, see with your admins how to allow it to access Internet) and configure your Maven client to use it ~or~
- Copy a "pre-populated" local repository from an existing machine to your machine and run maven offline (with all the limitations this implies) ~or~
- Don't use Maven
这篇关于Maven:如何以离线模式安装插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!