Configuring Jetty in pom.xml

To instantly run your java webapp after compiling, configure Jetty in pom.xml. This doesn't need an installation of Jetty server.
Jetty will be automatically downloaded, and your app will be deployed and server starts.

How to configure Jetty?
For those who are wondering "then how do I configure my server", here is the option. Copy the "webDefaultXml" from the jetty jar and add it to your resources. Now pass the location of the "webDefaultXml" to Jetty plugin.

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <configuration>
        <scanIntervalSeconds>10</scanIntervalSeconds>
        <webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
    </configuration>
</plugin>

What you can configure in webDefaultXml?
A sample of options that you can configure:
  • Directory Listing
  • gzip Compression
  • Memory mapped File buffer (updating this to false will fix your CSS and Image lock issue)
  • Cache Control
  • Servlet Mapping URL patterns (If you have a url that you want to be processed like *.jsp)

1 comment:

Unknown said...

This is extremely helpful info! Very good work. Everything is very interesting to learn and easy to understood. Thank you for giving information.
red ball 4 | ninjago games | red ball 3 | ninjago games