2 <!-- Generated by Apache Maven Doxia Site Renderer 1.6 at 2015-09-08 -->
3 <!-- Current: configuration.html -->
4 <!-- Active: index.html -->
5 <!-- Path: [index.html, configuration.html] -->
6 <!-- Skiplist: [index.html, configuration.html, export-mojo.html, debugging.html, skip.html, force.html, pitfalls.html] -->
9 <title>juplo - Hibernate 4 Maven Plugin - Configuration Examples</title>
10 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11 <link rel="canonical" href="http://juplo.de/hibernate4-maven-plugin/configuration.html"/>
12 <meta name="viewport" content="width=device-width, initial-scale=1" />
13 <link rel="stylesheet" type="text/css" href="/css/base.css" />
14 <style type="text/css">
15 @import '/css/screen.css' screen;
17 <script src="/js/prettify.js"></script>
19 <script src="/js/html5shiv.js"></script>
22 <link rel="stylesheet" type="text/css" href="/css/ie8.css" />
24 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
26 <body class="menu" onload="prettyPrint()">
27 <div id="page" class="cf">
29 <h1 id="logo"><a href="/" title="Home" class="l">juplo</a></h1>
30 <span id="slogan"><strong>Java</strong> bits from nerds for nerds</span>
34 <strong class="b title">You are here:</strong>
36 <li class="b"><a class="b" href="/">Home</a></li>
37 <li class="b"><a class="b" href="/projects.html">Projects</a></li>
38 <li class="b"><a class="b" href="./index.html">Hibernate 4 Maven Plugin</a></li>
39 <li class="b"><strong class="b">Configuration Examples</strong></li>
41 <a class="hide" href="#navigation">Jump to navigation</a>
44 <main class="content cf">
45 <article id="content" class="main">
46 <header><h1>Configuration Examples</h1></header>
52 <h2><a name="Configuration_through_a_hibernate.properties-File"></a>Configuration through a hibernate.properties-File</h2>
55 The most simple way to configure the plugin is, to put all the
56 hibernate-configuration in a <b>hibernate.properties</b>-file on your
57 classpath. Put the file in the <tt>resources</tt>-folder. Maven will put
58 it in the <tt>class</tt>-folder of your webapp, where it will be picked up
59 by this plugin as well as by Hibernate 4.
63 Doing so, the only additionally configuration needed, to activat the plugin
64 is the following entry in the <tt>plugins</tt>-section of your <tt>pom.xml</tt>:
68 <pre class="prettyprint linenums lang-html">
70 <groupId>de.juplo</groupId>
71 <artifactId>hibernate4-maven-plugin</artifactId>
72 <version>1.1.0</version>
76 <goal>export</goal>
80 </plugin></pre></div>
83 But be aware, that in this case the database-url, that is
84 build in the application is the same that is used while testing, where
85 the database is droped and recreated by the plugin.
88 you should never fire up this configuration on your production
89 system, or your database might be erased!
94 A better approach is, to specify a different url for testing like in the
99 <pre class="prettyprint linenums lang-html">
101 <groupId>de.juplo</groupId>
102 <artifactId>hibernate4-maven-plugin</artifactId>
103 <version>1.1.0</version>
107 <goal>export</goal>
111 <configuration>
112 <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
113 </configuration>
114 </plugin></pre></div>
117 Configuration properties, that are set in the <tt>configuration</tt>-section
118 of the plugin-configuration cannnot be overwritten elsewere (for details
119 see <a href="#precedence">Configuration-Method-Precedence</a>).
120 You never can overwrite them by accident when specifying a property on
121 the commandline or in your <tt>settings.xml</tt>.
124 <div class="section">
125 <h2><a name="Configuration_through_maven-properties"></a>Configuration through maven-properties</h2>
128 Alternatively, it is possible, to configure the plugin via maven-properties.
129 Each relevant configuration-option has a corresponding maven-property
130 (for a full list see the <a href="./export-mojo.html">Documentation of the export-Mojo</a>).
131 These are named after the
132 <a class="externalLink" href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc">Hibernate JDBC Properties</a>:
137 <li><tt>hibernate.connection.driver_class</tt></li>
139 <li><tt>hibernate.dialect</tt></li>
141 <li><tt>hibernate.connection.url</tt></li>
143 <li><tt>hibernate.connection.username</tt></li>
145 <li><tt>hibernate.connection.password</tt></li>
149 So, instead of writing the hibernate-configuration in the properties-file,
150 like above, you could put it in the <tt>properties</tt>-section of your
155 Thogether with the plugin-definition from above, the following would
156 be a complete configuration (again, the database-url was overwritten in
157 the plugin-configuration, to be sure to have a separate database for
162 <pre class="prettyprint linenums lang-html">
164 <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
165 <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
166 <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
167 <hibernate.connection.username>sa</hibernate.connection.username>
168 <hibernate.connection.password></hibernate.connection.password>
178 <groupId>de.juplo</groupId>
179 <artifactId>hibernate4-maven-plugin</artifactId>
180 <version>1.1.0</version>
184 <goal>export</goal>
188 <configuration>
189 <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
190 </configuration>
193 <plugins></pre></div>
195 <div class="section">
196 <h2><a name="Configuration_through_the_plugin-configuration"></a>Configuration through the plugin-configuration</h2>
199 A third way for configuring the plugin is the plugin-configuration.
200 The relevant configuration-parameters are:
205 <li><tt>driverClassName</tt></li>
207 <li><tt>hibernateDialect</tt></li>
209 <li><tt>url</tt></li>
211 <li><tt>username</tt></li>
213 <li><tt>password</tt></li>
217 The equivalent of the configuration from the last section would look
222 <pre class="prettyprint linenums lang-html">
224 <groupId>de.juplo</groupId>
225 <artifactId>hibernate4-maven-plugin</artifactId>
226 <version>1.1.0</version>
230 <goal>export</goal>
234 <configuration>
235 <driverClassName>org.hsqldb.jdbcDriver</driverClassName>
236 <hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
237 <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
238 <username>sa</username>
239 <password></password>
240 </configuration>
241 </plugin></pre></div>
244 The parameter <b>hibernateProperties</b> (name of the hibernate-properties-file
245 to use, defaults to <b>hibernate.properties</b>) can only be configured through
250 For more explanations, see the
251 <a href="./export-mojo.html">Documentation of the export-Mojo</a>.
254 <div class="section" id="precedence">
255 <h2 id="precedence">Configuration-Method-Precedence</h2>
258 The configuration is gathered in a fix order:
261 <ol style="list-style-type: decimal">
263 <li><tt>hibernate.properties</tt></li>
265 <li>maven-properties</li>
267 <li>plugin-configuration</li>
271 If you are in doubt about where a configuration-value comes from, run
272 maven with the <a href="./debugging.html">debug-output</a> enabled: <tt>mvn -X hibernate4:export</tt>
273 and be aware, that maven-properties can be overwitten on the command-line,
274 in your <tt>~/.m2/settings.xml</tt> and in a profile.
278 The plugin-configuration comes last and overwrites everything else.
279 That way, you can be sure, that a configuration-value, that is
280 specified in the plugin-configuration will never be overwritten by any
281 other configuration-method.
285 If you need to overwrite plugin-configuration-values with
286 maven-properties, you can use maven-properties in the plugin-configuration:
290 <pre class="prettyprint linenums lang-html">
292 <groupId>de.juplo</groupId>
293 <artifactId>hibernate4-maven-plugin</artifactId>
294 <version>1.1.0</version>
298 <goal>export</goal>
302 <configuration>
303 <password>${my-password-property}</password>
304 </configuration>
305 </plugin></pre></div>
309 <div class="marginal">
312 <a id="navigation"></a>
313 <a class="hide" href="#top" title="Show Content">Jump back to the top of the page</a>
314 <h2 class="nav menu">Section-Menu</h2>
316 <li class="m blog"><a href="/blog/" class="m">Blog</a></li>
317 <li class="m projects"><a href="/projects.html" class="m selected">Projects</a></li>
318 <li class="m about"><a href="/about.html" class="m">About</a></li>
320 <h2 class="nav submenu">
321 <span class="s">Submenu for section</span>
322 <a class="s selected" href="/projects.html">Projects</a>
324 <ul id="submenu" class="s">
326 <a class="s selected" href="./index.html">Hibernate 4 Maven Plugin</a>
327 <ul class="s active">
329 <strong class="s">Configuration Examples</strong>
332 <a href="export-mojo.html" class="s" title="Parameter Documentation">Parameter Documentation</a>
335 <a href="debugging.html" class="s" title="Enable Debug-Output">Enable Debug-Output</a>
338 <a href="skip.html" class="s" title="Skipping Execution">Skipping Execution</a>
341 <a href="force.html" class="s" title="Force Exceution">Force Exceution</a>
344 <a href="pitfalls.html" class="s" title="Known Pitfalls (FAQ)">Known Pitfalls (FAQ)</a>
347 <a href="project-info.html" class="s" title="Project Information">Project Information</a>
350 <a href="project-reports.html" class="s" title="Project Reports">Project Reports</a>
358 <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
359 <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
366 <ul id="footerlinks">
367 <li class="f" id="copyright">© <strong>mo</strong> 2015
369 <li class="f"><a class="f" href="/impressum.html">Impressum</a></li>
370 <li class="f about"><a class="f" href="/about.html">About</a></li>
374 <script type="text/javascript"><!--//--><![CDATA[//><!--
375 var _gaq = _gaq || [];
376 _gaq.push(['_setAccount', 'UA-571104-3']);
377 _gaq.push(['_trackPageview']);
379 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
380 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
381 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);