But what happens if the war uses external database? Especially when the datasource is defined externally to the war and accessed vie the JNDI?
Actually the solution if quite simple:
Step 1 - Define the Data-sourceCreate the file defining the data-source:
(The example below is for Oracle. See this page for examples of the other databases.
Pay attention to "jdbc/my_ds". It's the datasource JNDI name. Make sure to put there the actual JNDI name used by your application.
Place this file under your maven project. In my opinion the best is to place this file under src/dev/resources, but basically it can be anywhere.
To continue the example, I'll name the file: jetty-ds-dev.xml
Step 2 - Define the Jetty Maven Plugin
Pay attention to the configuration of jetty-ds-dev.xml.
Also pay attention that Jetty must be able to find the relevant JDBC driver in its classpath!
And basically that's all. Run "mvn jetty:run" and your application should work with the provided database.
Recommended Reading1. Apache Maven 3 Cookbook
2. Continuous Delivery: Reliable Software Releases through Build, Test, and Deployment Automation