Issue
I try to build .war file by using maven plugin:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
My project structure looks like:
/main/webapp/WEB-INF/
/main/webapp/WEB-INF/spring/...
/main/webapp/WEB-INF/web.xml
/main/webapp/public/...
/main/webapp/resources/...
/main/webapp/views/...
After building, my war file contains only WEB-INF and META-INF. All other content of webapp directory is missing (public, resources and views). Furthermore the WEB-INF dir in .war file consists only /classes and /lib directories (/WEB-INF/spring and WEB-INF/web.xml are missig).
How to tell maven to pack all webapp and WEB-INF directory content into war file?
Solution
There is a mismatch between your configuration of the maven-war-plugin
and the structure of your project. With <warSourceDirectory>WebContent</warSourceDirectory>
, you are configuration the maven-war-plugin
to look for your webapp sources inside the WebContent
directory. However, your sources are in main/webapp
.
I suggest you move all of your webapp sources inside src/main/webapp
(instead of main/webapp
) and update the maven-war-plugin
configuration to:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
By default, the maven-war-plugin
will be looking for your webapp sources inside src/main/webapp
.
Answered By - Tunaki
Answer Checked By - Mary Flores (JavaFixing Volunteer)