当我学习Ajax时候出现了错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-
plugin:2.1.1:war (default-war) on project CRPS: The specified web.xml file
'D:\WEB-INF\web.xml' does not exist-> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e > switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1]
如您所见,该插件在D:\ WEB-INF路径中查找以获取进行战争包装所需的web.xml,这显然是错误的地方。您需要通过在终端运行时传递-Dmaven.war.webxml = .... / WEB-INF / web.xml参数来明确指定,也可以通过添加以下内容将配置放入pom中
as you can see the plugin is looking in D:\WEB-INF path to get the web.xml needed to do war packaging and that's obviously wrong place to look. you need to specify explicitly either by passing -Dmaven.war.webxml=..../WEB-INF/web.xml argument at runtime on the terminal or you could put the configuration in your pom by adding
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<webXml>..../WEB-INF/web.xml</webXml>
</configuration>
</execution>
</executions>
</plugin>
请注意:您不需要声明绝对路径,到项目pom的相对路径就足够了。用正确的路径替换点。
我猜您没有使用默认的Maven War项目布局,这就是为什么您会收到此错误的原因。如果是的话,默认情况下,插件将按照以下示例从src / main / webapp / WEB-INF / web.xml中获取web.xml。
Please note: you don't need to declare the absolute path, relative path to your project pom should be sufficient. Replace the dots with the correct path.
I am guessing your are not using the default maven war project layout and that is why you are getting this error. if you were, the plugin would have got the web.xml from src/main/webapp/WEB-INF/web.xml by default as per the below example.
pom.xml
src
main
java
resources
webapp
WEB-INF
web.xml