为什么tomcat-maven-plugin试图部署到错误的URL?
我正在创建一个包含两个模块的虚拟maven项目,并且我已经包含了一个通用的pom.xml文件。 我能够从根pom.xml文件构建并运行所有测试,但是当它将文件部署到Tomcat时,它就会崩溃。 我的插件是:
dummy org.codehaus.mojo tomcat-maven-plugin http://127.0.0.1:8090/manager/text TomcatServer /dummy
的settings.xml
TomcatServer admin admin
但是,当我运行构建时,它使用默认配置值,我收到以下错误消息:
无法在项目webapp上执行目标org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy(default-cli):无法调用Tomcat管理器: http:// localhost:8080 / manager / deploy?path =%2Fwebapp&war = – > [帮助1]
有谁知道我怎么能让插件使用我的配置?
更多输出:
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ webapp --- [INFO] Packaging webapp [INFO] Assembling webapp [webapp] in [C:\Websites\www.dummy.app\webapp\target\webapp] [INFO] Processing war project [INFO] Copying webapp resources [C:\Websites\www.dummy.app\webapp\src\main\webapp] [INFO] Webapp assembled in [15 msecs] [INFO] Building war: C:\Websites\www.dummy.app\webapp\target\webapp.war [WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored (webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true') [INFO] [INFO] <<< tomcat-maven-plugin:1.1:deploy (default-cli) @ webapp << [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException [ERROR] [ERROR] After correcting the problems, you can resume the build with the command [ERROR] mvn -rf :webapp
谢谢
http://localhost:8080/manager/text
为我修好了。
尝试使用插件的2.0-beta-1版本 。
请参阅https://issues.apache.org/jira/browse/MTOMCAT-68
我也遇到了同样的问题。这就是我的解决方法。虽然这是一个迟到的答案,但我认为即使在今天这个答案仍然适用。
我正在使用tomcat7.the tomcat-maven-plugin:1.1默认为tomcat部署url http://localhost:8080/manager/html
,但对于tomcat 7 ,url已更改为http://localhost:8080/manager/text
。
步骤1:找到tomcat的url和角色来部署war文件。
我发现通过手动去
apache-tomcat-7.0.41\webapps\manager\WEB-INF\web.xml
用于部署的url是: / text ,因此maven应该使用http://localhost:8080/manager/text
此url的角色是“ manager-script ”
Text Manager interface (for scripts) /text/* manager-script
步骤2:为角色配置tomcat凭据
所以现在我们找到了部署war和角色的URL。如果你没有配置tomcat用户。下面是如何将角色添加到apache-tomcat-7.0.41 \ conf \ tomcat-users.xml。
步骤3:在pom.xml中配置tomcat-maven-plugin以使用tomcat url进行部署。
现在我们需要配置tomcat-maven-plugin来使用它们。下面是我在pom.xml中的插件配置。这将覆盖tomcat-maven-plugin的默认tomcat部署url。
org.codehaus.mojo tomcat-maven-plugin mytomcatserver http://localhost:8080/manager/text
步骤4:为tomcat url凭据配置maven的settings.xml。
现在,对于将war文件部署到tomcat的maven插件,它需要tomcat服务器的用户名和密码。 找出maven所在的settings.xml(我的是apache-maven-3.2.3 \ conf)并将以下配置应用于
mytomcatserver admin admin
第五步:真相的时刻
启动tomcat。
mvn包(war文件创建)
mvn tomcat:deploy(用于战争部署的tomcat控制台)
您的webapp将在http://localhost:8080/{context}