简体   繁体   English

如何使用tomcat / maven运行.war文件?

[英]How do I run a .war file with tomcat/maven?

I'm new to tomcat and maven configuration. 我是tomcat和maven配置的新手。 I was given a single .war that has all the dependencies in it. 我得到了一个包含所有依赖项的.war。 I'm trying to figure out how to run the war file on a given port configured using a pom.xml file 我试图弄清楚如何在使用pom.xml文件配置的给定端口上运行war文件

I tried mvn tomcat:run-war where the .war file lives but it obviously needs a pom.xml How can I configure this to be able to run this? 我尝试了mvn tomcat:run-war,.war文件所在的位置,但显然需要pom.xml。如何配置它才能运行此文件?

If you have already compiled project with all the dependencies in it then it has nothing to do with maven (because it's a tool for building projects from source code). 如果您已经编译了包含所有依赖项的项目,则它与maven无关(因为它是用于从源代码构建项目的工具)。

In order to deploy a war file you should install standalone tomcat on your system and drop the war file into webapps directory in the tomcat installation home folder, then (re)start tomcat. 为了部署war文件,您应该在系统上安装独立的tomcat并将war文件拖放到tomcat安装主文件夹中的webapps目录中,然后(重新)启动tomcat。 Give it 20-30 seconds to launch and open http://localhost:8080/war-file-name-without-dot-war in your browser, if everything went right then you will see the deployed application. 给它20至30秒的启动时间,然后在浏览器中打开http:// localhost:8080 / war-file-name-without-dot-war ,如果一切正常,那么您将看到已部署的应用程序。

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

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