FailOnMissingWebXml error while checking pom.xml in Eclipse

When compiling a Maven project, I get this error during the pom.xml validation pom.xml . This is a fairly large project with a complex build process. The project contains only JavaScript code and should not be compiled into war . I am also looking for a way:

  • Just disable the error by disabling failOnMissingWebXml (this seems to be a non-critical Eclipse error)
  • Find a solution that prevents this validation error in Eclipse (answers to related questions did not work for my specific scenario)

Full error:

 Description Resource Path Location Type web.xml is missing and <failOnMissingWebXml> is set to true pom.xml /testproject line 6 Maven Java EE Configuration Problem 

After clicking on the error, the problem seems to be in this pom.xml line:

  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.scs</groupId> <artifactId>scs-control-panel</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> **THE ERROR POINTS TO THIS LINE** <parent> <groupId>com.scs</groupId> <artifactId>scs</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../scs</relativePath> </parent> <build> </build> <dependencies> </dependencies> </project> 

Not sure if this is an Eclipse or Maven error, but probably Eclipse, since Maven runs smoothly through the command line. It may also be a bug in Eclipse, I am running the Eclipse Java EE IDE for web developers. Version: Mars.1 Release (4.5.1).

UPDATE1: I tried updating the project in Eclipse, but it did not make a difference.

UPDATE2: I tried changing the package type from war to pom , but no difference.

+5
source share
4 answers

Everything in Maven revolves around plugins. Plugins are programs that perform some kind of behavior during the build process. Some plugin inclusions are implied without having to declare anything.

These implied ones have default configurations. For example, maven-compiler-plugin included in all projects without announcing it. To override the default configurations, we need to declare the plugin in the pom.xml file and set the configurations. For example, you will see that many projects override the default value for maven-compiler-plugin , in which it has source and target installed on Java 1.5. We can change to 1.8

 <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> 

This is just the theory behind plugins to give you an idea of โ€‹โ€‹what's going on.

With that said, to use <packaging>war<packaging> , the maven-war-plugin used without having to declare anything. In the same way as using <packaging>jar</packaging> , the inclusion of maven-jar-plugin implied.

The default configuration for maven-war-plugin is an error in which there is no web.xml (this is a failOnMissingWebXml configuration failOnMissingWebXml ). Therefore, if we want to override this default value, we need to declare the plugin and then set the property to false (does not work)

 <build> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> 
+13
source
  • At

     mvn clean eclipse:clean 
  • Add this to your POM:

     <packaging>war</packaging> <properties> <failOnMissingWebXml>false</failOnMissingWebXml> </properties> 
+7
source

Add property below in POM.xml

  <failOnMissingWebXml>false</failOnMissingWebXml> 
+1
source

I think the easiest way is to choose the version of the war 3 plugin. The default value for failOnMissingWebXml has been changed from true to false .

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.0.0</version> </plugin> 

Once you have installed in your pom, the nasty bug disappears forever.

0
source

Source: https://habr.com/ru/post/1235234/


All Articles