Web applications 无法在maven项目中构建war
有两个问题:我的maven项目在Eclipse中的运行方式——服务器上运行不会出现。 2) 因此,我想直接在tomcat服务器中运行,当我尝试创建war时,出现以下错误。请帮助我,我的web.xml仅位于指定路径中Web applications 无法在maven项目中构建war,web-applications,maven,Web Applications,Maven,有两个问题:我的maven项目在Eclipse中的运行方式——服务器上运行不会出现。 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 f
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 -
我认为这个错误是可以自我解释的。您的项目中没有
web.xml
。这是有意的吗?理论上,您可以拥有一个WAR文件,而不需要web.xml
文件,因为Servlet3.0支持这种部署。在这种情况下,您必须如下配置maven war插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>${applicationContextName}</warName>
<packagingExcludes>
AFolder,
aFile.xml
</packagingExcludes>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
maven战争插件
2.2
假的
您的web.xml可能不在标准位置。一些Eclipse项目创建向导将web.xml放在WebContent/web\u-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>
...
org.apache.maven.plugins
maven战争插件
WebContent\WEB-INF\WEB.xml
...
我想你在寻找这样的东西:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>${applicationContextName}</warName>
<packagingExcludes>
AFolder,
aFile.xml
</packagingExcludes>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
maven战争插件
2.6
${applicationContextName}
一个文件夹,
aFile.xml
默认战争
包裹
战争
web.xml在指定的路径中,所以文件在那里,但Maven抱怨没有?可能是文件权限问题?是的,当然,因为文档明确声明failOnMissingWebXml是必需的。对于chkal提到Servlet3.0异常,我要额外竖起大拇指,这是非常正确的!