我想使用maven将web应用程序部署到tomcat。但我无法下载tomcat maven插件错误。
我的pom.xml的一部分
<build>
<finalName>cdmi-server</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<!--<artifactId>maven-compiler-plugin</artifactId>-->
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<url>http://127.0.0.1:8080/manager</url>
<server>TomcatServer</server>
<path>/cdmi-server</path>
</configuration>
</plugin>
</plugins>
</build>
...
<pluginRepositories>
<pluginRepository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</pluginRepository>
<pluginRepository>
<id>maven-repository.dev.java.net</id>
<name>Java.net Maven 1 Repository (legacy)</name>
<url>http://download.java.net/maven/1</url>
<layout>legacy</layout>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>m1.dev.java.net</id>
<url>http://download.java.net/maven/1</url>
<layout>legacy</layout>
</repository>
<repository>
<id>m2.dev.java.net</id>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</repository>
</repositories>
Tomcat的users.xml中:
<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="password" roles="admin,manager"/>
的settings.xml(行家):
<servers>
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
当我运行mvn:install,
时,我得到的错误Project ID: org.codehaus.mojo:tomcat-maven-plugin
Reason: POM 'org.codehaus.mojo:tomcat-maven-plugin' not found in repository: Unable to download the artifact from any repository
org.codehaus.mojo:tomcat-maven-plugin:pom:2.0.2
from the specified remote repositories:
m2.dev.java.net (http://download.java.net/maven/2),
central (http://repo1.maven.org/maven2),
maven2-repository.dev.java.net (http://download.java.net/maven/2/),
maven-repository.dev.java.net (http://download.java.net/maven/1),
m1.dev.java.net (http://download.java.net/maven/1)
for project org.codehaus.mojo:tomcat-maven-plugin
如何解决错误?
答案 0 :(得分:4)
根据官方页面,您需要更改插件声明:
由于版本2.0-beta-1 tomcat mojos已被重命名为tomcat6和tomcat7,目标相同。
您必须配置您的pom才能使用这个新的groupId:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</pluginManagement>
codehaus版本stopped at v1.1
答案 1 :(得分:3)