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?
Best Answer
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 themaven-war-plugin
to look for your webapp sources inside theWebContent
directory. However, your sources are inmain/webapp
.I suggest you move all of your webapp sources inside
src/main/webapp
(instead ofmain/webapp
) and update themaven-war-plugin
configuration to:By default, the
maven-war-plugin
will be looking for your webapp sources insidesrc/main/webapp
.