Fix Maven's web.xml is MissingError

Fix Maven's web.xml is MissingError


Fix Maven's web.xml is MissingError

When you create a new Maven web project you often see the ‘web.xml is missing and failOnMissingWebXml is set to true’ error message. The fix? To just add a build entry, reference the Maven maven-war-plugin, and tell Maven you’ll be using annotations in your project and won’t need no pesky web.xml file. Well, actually, you just set Maven’s failOnMissingWebXml setting to false which achieves the same goal. It’s a quick fix to rid yourself of the web.xml is missing Maven error.


Content

0.399 -> hey i'm cameron mckenzie at cameron mcnz
2.8 -> on twitter and i just wanted to quickly
4.56 -> show you how to get rid of that annoying
6.48 -> web.xml is
7.919 -> missing error message that you get in
10.4 -> eclipse on the pom file
12 -> when you create a new web module in the
14.32 -> tool
15.36 -> so let me show you the problem that we
17.039 -> have with a web module that doesn't have
19.84 -> any web.xml file in it i'm going to open
23.119 -> a new maven project create a brand new
25.359 -> maven project make it a
26.72 -> simple maven project and the group id
29.88 -> com.mcnz
31.039 -> and artifact no web
34.32 -> xml and i'm going to make this a type
36.719 -> war file and normally
38.16 -> well historically war files have had
40.64 -> web.xml files in their web inf folder
43.04 -> and if you end up
44 -> creating a new war file with maven and
47.12 -> you haven't specified any other
48.879 -> archetype
49.84 -> notice it'll bark at you to get a little
51.44 -> bit of a clap back here and it says to
53.52 -> me web.xml is
55.039 -> missing gives me a white x some people
57.92 -> say it's a red x it's not it's a white x
60.16 -> it gives me a white x it says web dot
61.92 -> xml is missing so
63.76 -> how do you fix it well it's real easy to
66.159 -> fix it all you have to do
67.84 -> is add a plugin to your build element
71.119 -> in the palm file of your maven project
74.159 -> so i'm going to paste that in here and
75.68 -> just
76.4 -> talk about it for a second so right
78.72 -> there i've put in this
79.84 -> maven war plug-in 331 is the version and
82.88 -> i've just put this entry in here
84.72 -> fail on missing web xml and set that to
87.759 -> false so otherwise it's going to fail
89.84 -> on a missing web.xml file that's all you
93.2 -> need
93.6 -> in order to get rid of that error i'm
95.119 -> going to click control s
96.799 -> i'm going to right click and say maven
100.079 -> update project click ok
103.36 -> and that just kind of shakes the tree a
105.6 -> little bit gets it to
107.28 -> recognize that setting and all of a
109.52 -> sudden that
110.56 -> white x on the red circle goes away and
114 -> so that's all you need to do just add
115.6 -> that
116.479 -> maven war plugin to the plugin section
119.36 -> of the build element of your palm file
121.28 -> and it goes away
122.399 -> by the way i did also include the
126.159 -> maven compiler configuration where i set
128.239 -> the source code to 1.8
130.319 -> you can actually put a release tag in
131.84 -> there and say release 11 or at least 13
134.4 -> if you want to use a different version
136 -> that's always a good thing to put in as
137.44 -> well that's not necessary for this
139.599 -> solution though although if you don't
141.92 -> have that you may end up getting some
143.84 -> sort of error about not supporting java
146.08 -> 1.5
147.2 -> but as far as fixing that
150.319 -> no web.xml in your project that's all
153.12 -> you have to do
154.08 -> and by the way i guess the other option
155.76 -> is to actually put a web.xml file in
157.84 -> your project but
159.36 -> who wants to do that and there you go
161.68 -> that's how easy it is to fix that
163.2 -> web.xml is missing maven air if you
165.519 -> enjoy this tutorial head over to
167.239 -> theserverside.com i'm the
168.48 -> editor-in-chief over there we've got
169.519 -> lots of
170 -> great enterprise software development
172 -> tutorials over there
173.44 -> if you're interested in my personal
174.48 -> antics you can follow me on twitter
176.36 -> cameronmcnz
177.519 -> and subscribe on youtube

Source: https://www.youtube.com/watch?v=Jd2jPvv_1uo