java Maven 无法下载 tomcat-maven-plugin 快照
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2013576/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven is failing to download the tomcat-maven-plugin snapshot
提问by Justin Searls
Even after wiping out my settings.xml, I still get this error when trying to use this snapshot dependency. Given the dependency:
即使在删除我的 settings.xml 之后,我在尝试使用此快照依赖项时仍然会收到此错误。鉴于依赖:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<path>/licensing</path>
<tomcatWebXml>${basedir}/src/main/mock/web.xml</tomcatWebXml>
</configuration>
</plugin>
And (in the POM), the plugin repository definition:
并且(在 POM 中),插件存储库定义:
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled> <!-- Workaround for MNG-2974, see note below -->
</releases>
</pluginRepository>
I'm left with the following 404 error. If I actually navigate out to that repo, the jar it's looking for isn't there, just dated ones (I'm not familiar with the mechanics of how Maven ultimately resolves expected dependency names).
我留下了以下 404 错误。如果我真的导航到那个 repo,它正在寻找的 jar 不在那里,只是过时的(我不熟悉 Maven 最终如何解析预期依赖名称的机制)。
Ideas?
想法?
Downloading: http://snapshots.repository.codehaus.org/org/codehaus/mojo/tomcat-maven-plugin/1.0-SNAPSHOT/tomcat-maven-pl
ugin-1.0-SNAPSHOT.jar
[INFO] Unable to find resource 'org.codehaus.mojo:tomcat-maven-plugin:maven-plugin:1.0-SNAPSHOT' in repository Codehaus
Snapshots (http://snapshots.repository.codehaus.org)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to downl
oad the artifact from any repository
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=org.codehaus.mojo -DartifactId=tomcat-maven-plugin -Dversion=1.0-SNAPSHOT -Dpacka
ging=maven-plugin -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.codehaus.mojo -DartifactId=tomcat-maven-plugin -Dversion=1.0-SNAPSHOT -Dpackagi
ng=maven-plugin -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
org.codehaus.mojo:tomcat-maven-plugin:maven-plugin:1.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
Codehaus Snapshots (http://snapshots.repository.codehaus.org)
org.codehaus.mojo:tomcat-maven-plugin:maven-plugin:1.0-SNAPSHOT
from the specified remote repositories:
central (http://repo1.maven.org/maven2),
Codehaus Snapshots (http://snapshots.repository.codehaus.org)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Jan 06 10:06:49 EST 2010
[INFO] Final Memory: 14M/36M
[INFO] ------------------------------------------------------------------------
回答by Pascal Thivent
I rechecked and, with the following pom fragments:
我重新检查,并使用以下 pom 片段:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
...
<pluginRepositories>
<pluginRepository>
<id>Codehaus Snapshots</id>
<url>http://snapshots.repository.codehaus.org/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled> <!-- Workaround for MNG-2974, see note below -->
</releases>
</pluginRepository>
</pluginRepositories>
...
<build>
<finalName>my-webapp</finalName>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
</plugin>
...
</plugins>
...
</build>
</project>
The SNAPSHOT of the plugin has been downloaded successfully:
插件的SNAPSHOT已经下载成功:
$ mvn clean
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building my-webapp Maven Webapp
[INFO] task-segment: [clean]
[INFO] ------------------------------------------------------------------------
[INFO] snapshot org.codehaus.mojo:tomcat-maven-plugin:1.0-SNAPSHOT: checking for updates from Codehaus Snapshots
[INFO] snapshot org.codehaus.mojo:tomcat-maven-plugin:1.0-SNAPSHOT: checking for updates from maven2-repository.dev.java.net
Downloading: http://snapshots.repository.codehaus.org//org/codehaus/mojo/tomcat-maven-plugin/1.0-SNAPSHOT/tomcat-maven-plugin-1.0-20091222.232027-11.pom
5K downloaded (tomcat-maven-plugin-1.0-20091222.232027-11.pom)
Downloading: http://snapshots.repository.codehaus.org//org/codehaus/mojo/tomcat-maven-plugin/1.0-SNAPSHOT/tomcat-maven-plugin-1.0-20091222.232027-11.jar
48K downloaded (tomcat-maven-plugin-1.0-20091222.232027-11.jar)
[INFO] [clean:clean {execution: default-clean}]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9 seconds
[INFO] Finished at: Wed Jan 06 16:13:28 CET 2010
[INFO] Final Memory: 7M/78M
[INFO] ------------------------------------------------------------------------
It's very weird because I can't see any difference, but things are working as expected. In other words, I can't reproduce...
这很奇怪,因为我看不出任何区别,但事情按预期工作。换句话说,我无法复制...
In your local repository, do you have maven-metadata*.xmlfiles in the 1.0-SNAPSHOT directory for the tomcat-maven-plugin artifact? Do they match the ones on the remote server? Do they correctly specify the build number and timestamp?
在您的本地存储库中,您maven-metadata*.xml在 1.0-SNAPSHOT 目录中是否有用于 tomcat-maven-plugin 工件的文件?它们与远程服务器上的匹配吗?他们是否正确指定了内部版本号和时间戳?
If they are incorrect locally, running maven with -Umight help.
如果它们在本地不正确,运行 maven with-U可能会有所帮助。
You might also check mvn help:effective-pomand see what Maven thinks the updatePolicyis for snapshots on that repository.
您还可以检查mvn help:effective-pom并查看 Maven 认为该updatePolicy存储库上的快照是什么。
Or maybe just delete your tomcat-maven-plugin artifact from your local repository and try again.
或者也许只是从本地存储库中删除您的 tomcat-maven-plugin 工件,然后重试。
If nothing helps, try to install it manually (download the plugin from the repository and use the mvn install:install-filemojo) or checkout the sources from the VCS and build it locally. But these options are just workarounds, you have a problem somewhere (what version of maven are you using?).
如果没有任何帮助,请尝试手动安装它(从存储库下载插件并使用mvn install:install-filemojo)或从 VCS 检出源代码并在本地构建它。但是这些选项只是解决方法,您在某处遇到了问题(您使用的是什么版本的 maven?)。
回答by Andre
I know this post is a little old, but the tomcat maven plugin has been moved to the apache maven repository. Codehaus only hosts version 1.0 of the plugin. If you want 2.0-snapshot (so you can run tomcat 7), you need to change your pom.xml a little bit. Note that 2.0 is under development.
我知道这个帖子有点旧,但是 tomcat maven 插件已经移到了 apache maven 仓库。Codehaus 仅托管插件的 1.0 版。如果你想要 2.0-snapshot(所以你可以运行 tomcat 7),你需要稍微改变你的 pom.xml。请注意,2.0 正在开发中。
<repositories>
...
<repository>
<id>people.apache.snapshots</id>
<url>http://repository.apache.org/content/groups/snapshots-group/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Apache Snapshots</name>
<url>http://repository.apache.org/content/groups/snapshots-group/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
And your plugin configuration goes like this:
你的插件配置是这样的:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
</plugin>
回答by Upgradingdave
Not sure exactly, but looks like they might be using some form of the "buildnumber"maven plugin to include version control revision numbers.
不确定,但看起来他们可能正在使用某种形式的“buildnumber”maven 插件来包含版本控制修订号。
Take a look at http://snapshots.repository.codehaus.org//org/codehaus/mojo/tomcat-maven-plugin/1.0-SNAPSHOT/maven-metadata.xmland you'll notice that in addition to the normal stuff, theres a xml tag for buildnumber and timestamp.
看看http://snapshots.repository.codehaus.org//org/codehaus/mojo/tomcat-maven-plugin/1.0-SNAPSHOT/maven-metadata.xml你会注意到除了正常的东西, 有一个用于构建编号和时间戳的 xml 标记。
This may not be ideal, but you might be able to replace:
这可能并不理想,但您可以替换:
<version>1.0-SNAPSHOT</version>
with:
和:
<version>1.0-20091222.232027-11</version>
To at least get up and running with the latest version of the plugin.
至少要启动并运行最新版本的插件。
回答by CA Martin
First off let me say that you do not download the TomCat-Maven-Plugin for Eclipse like other Eclipse plugins.
首先让我说您不像其他 Eclipse 插件那样下载 Eclipse 的 TomCat-Maven-Plugin。
You simply use the maven tools in Eclipse, to insert the correct maven plugin build commands into your maven pom.xml file.....
您只需使用 Eclipse 中的 maven 工具,将正确的 maven 插件构建命令插入到您的 maven pom.xml 文件中.....
If anyone is having trouble understanding how to get their Maven project to run as a maven Build configuration, there are a couple of things you may need to look for:
如果有人在理解如何让他们的 Maven 项目作为 Maven 构建配置运行时遇到问题,您可能需要寻找以下几点:
I would like to upload an image but oh well....
我想上传一张图片,但是哦....
In your Eclipse Web App, hopefully you have a Maven POM.xml file, if not you need to set that up first.
在您的 Eclipse Web App 中,希望您有一个 Maven POM.xml 文件,如果没有,您需要先设置它。
Then, you can right click on it and then find Maven in your menu, then the sub menu item comes up, with a choice called Add Plugin.
然后,您可以右键单击它,然后在您的菜单中找到 Maven,然后出现子菜单项,其中有一个名为 Add Plugin 的选项。
There is a field called "Enter groupId, artifactId or sha1, etc.... Type in the word Tomcat there.
有一个名为“输入 groupId、artifactId 或 sha1 等的字段......在那里输入单词 Tomcat。
It will then load search results in the box below.
然后它将在下面的框中加载搜索结果。
Basically what this does is load details in your pom.xml as to which plugins to download when building with Maven.
基本上,它的作用是在 pom.xml 中加载有关使用 Maven 构建时要下载哪些插件的详细信息。
After that you need to do the Maven build.
之后,您需要进行 Maven 构建。
Then, you want to go to Run Configurations and make sure you have the correct path to where your webapp lives.
然后,您要转到运行配置并确保您的 web 应用程序所在的路径正确。
Also in that page, under goals type TomCat:run Then apply Finally run.
同样在该页面中,在目标下键入 TomCat:run 然后应用 最后运行。
If all goes well you will have a Tomcat server running the web app. Then you can go to a browser and enter [http://localhost:8080/webappname/defaultpagename]
如果一切顺利,您将拥有一个运行 Web 应用程序的 Tomcat 服务器。然后你可以在浏览器中输入 [http://localhost:8080/webappname/defaultpagename]
and walla!
和瓦拉!

