无法在maven项目中建立战争

Ren*_*nta 6 web-applications maven

几个问题:在Eclipse中我的maven项目运行为 - 在服务器上运行不会到来.2)所以我想直接在tomcat服务器上运行,当我尝试创建war时,会出现以下错误.请帮助我,我只在指定的路径中使用我的web.xml

   Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war)
 on project SchoolMgmtApp: The specified web.xml file 
'F:\WorkSpace\SchoolMgmtApp\src\main\webapp\WEB-INF\web.xml' does not exist -
Run Code Online (Sandbox Code Playgroud)

chk*_*kal 22

我认为这个错误是自我解释的.你web.xml的项目没有.这是有意的吗?理论上,您可以拥有一个没有web.xml文件的WAR文件,因为Servlet 3.0支持这种部署.在这种情况下,你必须像这样配置maven-war-plugin:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.2</version>
  <configuration>
    <failOnMissingWebXml>false</failOnMissingWebXml>
  </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)


Mic*_*sey 5

您的web.xml可能不在标准位置.一些Eclipse项目创建向导将web.xml放在WebContent/WEB_INF中.在这种情况下,你可以重新安排项目,以便maven喜欢它,或者你可以告诉maven在pom.xml中找到你的web.xml的位置.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <webXml>WebContent\WEB-INF\web.xml</webXml>
    ...
Run Code Online (Sandbox Code Playgroud)