2021-05-09 maven编译错误war

当我学习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

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容