简体   繁体   English

使用Maven部署Tomcat

[英]Deploy Tomcat using Maven

I want to deploy the tomcat on production and jar on non-embedded tomcat using Maven. 我想使用Maven在生产环境中部署tomcat,在非嵌入式tomcat上部署jar。 I have added Tomcat7 Maven Plugin in POM.XML but running mvn tomcat7:run runs the application on embedded tomcat. 我在POM.XML中添加了Tomcat7 Maven插件,但是运行mvn tomcat7:run在嵌入式tomcat上运行应用程序。

Can anyone explain, how to deploy and run application on non-embedded tomcat using maven. 谁能解释一下如何使用Maven在非嵌入式tomcat上部署和运行应用程序。 And as i am new in tomcat, maven and java, could anyone please explain what is embedded tomcat for? 而且由于我是tomcat,maven和java的新手,所以谁能解释一下嵌入式tomcat的用途是什么?

I guess your pom.xml must have this configuration: 我猜您的pom.xml必须具有以下配置:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
        <url>http://127.0.0.1:8080/manager</url>
        <server>TomcatServer</server>
        <path>/MyWebApp</path>
    </configuration>
</plugin>

%TOMCAT_HOME%/conf/tomcat-users.xml %TOMCAT_HOME%/ conf / tomcat-users.xml

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="user" password="password" roles="admin,manager"/>
</tomcat-users>

%MAVEN_HOME%/conf/settings.xml %MAVEN_HOME%/ conf / settings.xml

<server>
    <id>TomcatServer</id>
    <username>admin</username>
    <password>password</password>
</server>

Having done this, use the command tomcat7:deploy or tomcat7:redeploy 完成此操作后,请使用命令tomcat7:deploytomcat7:redeploy

More documentation here 此处有更多文档

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

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