Maven Tutorial 07 - Using the Jetty Plugin

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we saw one of the maven plugins in our earlier tutorial which was the compiler plugin there are a few other plugins that are available that are very helpful when you do the pickup locations one common thing that you do when you're developing web applications is to build and deploy in a server on a can or a container so there are a few servers and servlet containers available in maven as plugins that you can use in order to you know deploy the web application that you are developing and the advantage here is that it you know integrates with the work flow and you can do a whole lot of things automatically now we have plugins for Tomcat and we have plugins for jetty which is a lightweight servlet container I'm going to use jetty in this tutorial and you know you can use Tomcat plug-in also in a similar vein so the first step in order to use any plug-in is to declare the plug-in in our pom dot XML so here's my four node XML and an opponent with an editor now here in order to mention what plugin I need to use again I need to use the standard maven coordinate the group ID artifact ID and the version but the difference here is that here dependencies are required for the chord these are dependencies for the code but when I'm using plugins that is something that I want maven to use when we are actually building so this is something that we need to configure in a different node so at the end of the dependencies node here what I will do is use the billet node inside this all my plugins are going to go okay so build plugins will contain all the plugins that I'm gonna use so the plug-in that I want to use now is the jetty plugin so I'll have a plug-in node here and here what I'll do is I will provide the group ID artifact ID and the version for this plugin you just copy this to save some time so the group ID for the jetty plug-in I know is org or beta jetty again this is something that you can look up online if you're not sure then the artifact ID for the chilli plug in this amazing - jetty plug-in and the version that I'm gonna use with this is 610 okay so I have defined this plug-in here in the bill to again build plugins and add all the plugins you want every plug-in is identified by a plug-in node and it has the group ID artifact and the version of that plug-in now let's save this and close okay so now what I've done is I've defined the plugin so that I can use it in my build commands and now I will run the command so that even can execute that I'll say mvn of course first make sure the river in the territory we have the bound or eczema now I will run vn JT : run so here the part of the command before the colon tells me when what is the plugin that needs to handle this command and the second part of the command after the golden tells what plugin should do so now if I hit enter maven will detect that there is this plugin that I have defined in my formed or XML now it's gonna go and download all the required components from the central repository I don't have it in my local repository because it's the first time I'm running this so it's gonna go talk to the central repository and it's going to download the runtimes so it's gonna take a while so I will just resume the video after the download is complete okay so here you see a message it says started jenny server so let's access this server open up a browser and i will type localhost colon 8080 because this is the default for a jetty now here it says that there is no page to hand you the root but it tells you that there is the slash my web app which is the application that we have developed so I will type my map and there you go our application our code has been deployed in this jetty container so what this je : Run has done us first it is read this Palm D'Or XML and it has identified that this is the plugin that needs to run and then what it's done as it has compiled built the application that is denoted by this bound or XML and it has deployed this inside the GD container so I can access the application directly in Dom CAD what would happen is if I just enter localhost colon 8080 we would get a welcome page jetty doesn't have a welcome page so that's the reason might be getting a 404 but it has also printed out the call at the web application context that it knows and that is application which we were able to access by specifying the URL so this should give you an idea about how easy it is to develop web applications you just have to run the article and generate command and you have the whole source code structure ready and then you just have to run they know ambien Jerry : run after mentioning the plugin in the pound or eczema and it automatically takes care of building the application and then deploying it for you there's one thing to note here now let me go to this source code folder and in my web app I have this index dot JSP now what I'll do is I'll make a change here to this JSP page and I will save it now if i refresh this it automatically gets updated but say what if it was it was a class which needed to be compiled so in that case what we can do is we can go to this bomb dot XML and I can configure this jetty plugin to listen to class changes and if there is a change in any of the Java files I can ask the you know ask for the compilation of those plugins and then deploying them automatically so this is a configuration that we can do so this is a sample configuration I'm going to show you here as we saw in the compiler example in the Palm D'Or XML wherever I am declaring the plug-in I can also mention what is the configuration that I need so what I do is I into configuration node here and here I can enter all the configurations that I want to make here I'm going to use the example of the auto check for any changes to our class files so I use the configuration scan interval seconds so this is a configuration that JD has and it checks for any changes in a given scan interval by default the scan interval in seconds value is zero so JD is not going to make the but you can specify a value here so let's say I use a value of five it's gonna check every five seconds for any changes any updates to our Java files and then if there is an update jetty automatically packages and deploys it so you will always have the latest version when you're accessing that so this takes care of you know the whole intermediate set of steps that we need to do when we are developing web applications whenever you make a change we need to build and deploy and all that stuff so that has completely avoided here in this case jetty is going to take care of that as long as you mention the scan interval here so this is a this is one of the useful ways in which we can we can speed up our development and by looking at this we've also seen how to configure plugins and we also seen how plugins can not only change the way the core maven works we can also add an extra functionality like a whole servlet container just by defining the plugin in the pomerode XML and then configuring it to suit our needs
Info
Channel: Java Brains
Views: 151,933
Rating: undefined out of 5
Keywords: maven, build, apache, tutorial, technology, computers, java, free, j2ee, ee, educational, eclipse, tomcat, javabrains, brains, koushik
Id: 6sIhJuaZhF0
Channel Id: undefined
Length: 9min 34sec (574 seconds)
Published: Wed Jun 15 2011
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.