zaterdag 14 juli 2007

maven and jetty for quick dev deploy

Jetty is a java powered lightweight servlet container. It can be used as an embedded container bringing webapps closer to desktop applications. But that's another story. Here I will quickly explain how you can even quicker deploy your webapp on a jetty container using the maven jetty plugin.

All you need to do is add some configuration for the jetty plugin in you pom file. Like this basic config:

<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>be.cappelleh.test</groupId>
<artifactId>test</artifactId>
<name>test</name>
<version>1.0-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<useTestClasspath>true</useTestClasspath>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- dependencies here -->
</dependencies>
</project>


Next you can run your application using the following goal

mvn jetty:run


First time will take a bit longer because of the dependencies that need to be downloaded. Once up and running you'll see

[INFO] Started Jetty Server
[INFO] Starting scanner at interval of 10 seconds.


And that means your application is waiting for you at (replace yourContext with your project context)

http://localhost:8080/yourContext


sources:
o jetty project homepage
o maven jetty plugin config
o maven jetty plugin goals
o more on jetty

Geen opmerkingen:

Een reactie plaatsen