Created
October 4, 2012 11:23
-
-
Save leonelag/3833036 to your computer and use it in GitHub Desktop.
How to add dependencies to a project run with jetty-maven-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Example of data source configuration for Jetty 8 | |
--> | |
<?xml version="1.0"?> | |
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd"> | |
<Configure class="org.eclipse.jetty.webapp.WebAppContext"> | |
<Set name="contextPath">/myapp</Set> | |
<New id="MyDataSource" class="org.eclipse.jetty.plus.jndi.Resource"> | |
<Arg>jdbc/backendDS</Arg> | |
<Arg> | |
<New class="org.apache.commons.dbcp.BasicDataSource"> | |
<!-- Driver for Oracle 9i --> | |
<!-- | |
<Set name="driverClassName">oracle.jdbc.driver.OracleDriver</Set> | |
--> | |
<!-- Driver for Oracle 10g and 11g --> | |
<Set name="driverClassName">oracle.jdbc.OracleDriver</Set> | |
<Set name="url">jdbc:oracle:thin:@localhost:1521:XE</Set> | |
<Set name="username">myuser</Set> | |
<Set name="password">myuser</Set> | |
</New> | |
</Arg> | |
</New> | |
</Configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Problem: your application needs a data source (let's say Oracle); you want to | |
run it with jetty-maven-plugin by using 'mvn jetty:run'. Thus, you need the | |
Jetty server to start with the database driver in its class path, but you do | |
not want to add it as a dependency, because you do not want it added to the | |
final packaged artifact. | |
The solution is to add the dependency to the plugin itself, as shown below. | |
--> | |
<plugin> | |
<groupId>org.mortbay.jetty</groupId> | |
<artifactId>jetty-maven-plugin</artifactId> | |
<version>8.1.7.v20120910</version> | |
<configuration> | |
<scanIntervalSeconds>10</scanIntervalSeconds> | |
<webApp> | |
<contextPath>/myapp</contextPath> | |
</webApp> | |
</configuration> | |
<dependencies> | |
<dependency> | |
<groupId>com.oracle</groupId> | |
<artifactId>ojdbc14</artifactId> | |
<version>11.2.0.3</version> | |
</dependency> | |
</dependencies> | |
</plugin> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How did your jetty-env.xml get injected into the plugin in POM?