简体   繁体   English

使用生成的webapp文件夹将Maven项目部署到Apache Tomcat

[英]Deploy a Maven project with a generated webapp folder to Apache Tomcat

I am trying to build/deploy/run this maven/apache tomcat project LODE . 我正在尝试构建/部署/运行这个maven / apache tomcat项目LODE

It's quite the first time I see this style of java web applications. 这是我第一次看到这种风格的Java Web应用程序。 I Followed the instructions provided on the website of this project. 我按照本项目网站上提供的说明进行操作。 Started with maven clean install . 开始使用maven clean install Then an src folder was generated with a java folder (containing java classes) and a webapp folder (containing web resources) See the photo. 然后生成一个src文件夹,其中包含一个java文件夹(包含java类)和一个webapp文件夹(包含Web资源)。请参阅照片。

I am used to having a structure where a WebContent folder is there and a WAR file can generated. 我习惯于拥有一个WebContent文件夹所在的结构,并且可以生成WAR文件。

来自我的eclipse IDE的照片 .

How to deploy this project into apache tomcat and get it to run? 如何将这个项目部署到apache tomcat并让它运行?

Here is what I tried: 这是我尝试过的:

  1. I tried generating a war file by editing the build section in pom.xml file. 我尝试通过编辑pom.xml文件中的构建部分来生成war文件。 However, it did not work. 但是,它没有用。
  2. I tried to add the project to Apache Tomcat 9 in my eclipse IDE. 我试图在我的eclipse IDE中将项目添加到Apache Tomcat 9。 However, Tomcat does not believe that this is a web project, so I cannot add it (using right click on Tomcat -> Add/Remove). 但是,Tomcat不相信这是一个Web项目,所以我无法添加它(使用右键单击Tomcat - >添加/删除)。
  3. I tried to take the generated webapp folder and deploy it to Tomcat (without eclipse IDE --> tomcat manager ' http://localhost:8081/manager/html ' --> Deploy Directory) after creating WEB-INF/classes folder and moving the source qualified packages from the generated src folder to this folder. 在创建WEB-INF / classes文件夹之后,我尝试将生成的webapp文件夹部署到Tomcat(没有eclipse IDE - > tomcat manager'http:// @ host:8081 / manager / html ' - > Deploy Directory)将源限定包从生成的src文件夹移动到此文件夹。 This did not work because the java classes were missing (cannot find the java class/package error). 这不起作用,因为缺少java类(找不到java类/包错误)。

LODE's README clearly says how to lunch the application. LODE的README清楚地说明了如何在应用程序中共进午餐。 Well you don't see a war thus can't deploy on tomcat server. 好吧,你没有看到战争,因此无法在tomcat服务器上部署。

I found two ways to make it work: 我发现了两种方法可以使它工作:

  1. mvn clean jetty:run from the terminal. mvn clean jetty:run从终端mvn clean jetty:run This will just work fine (runs on the jetty server). 这将正常工作(在jetty服务器上运行)。

  2. For tomcat server, add <packaging>war</packaging> in the pom.xml to generate the war. 对于tomcat服务器,在pom.xml中添加<packaging>war</packaging>以生成war。 Then either rename the generated war manually (for example, LODE-1.3-SNAPSHOT.war to lode.war) or use maven plugins to generate the war name. 然后手动重命名生成的war(例如,LODE-1.3-SNAPSHOT.war为lode.war)或使用maven插件生成war名称。 Now deploy this war to your tomcat server as usual. 现在像往常一样将此战争部署到您的tomcat服务器。

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

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