2 <!-- Generated by Apache Maven Doxia Site Renderer at Nov 10, 2015 -->
3 <!-- Current: configuration.html -->
4 <!-- Active: index.html -->
6 <!-- Skiplist: [index.html, getting-started.html] -->
9 <title>juplo - </title>
10 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
11 <link rel="canonical" href="http://www.juplo.de/facebook-utils/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">Juplo - Facebook Utils</a></li>
39 <li class="b"><strong class="b">$shortTitle</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>$shortTitle</h1></header>
50 <div class="section"><h2>Configuration through a hibernate.properties-File<a name="Configuration_through_a_hibernate.properties-File"></a></h2>
52 The most simple way to configure the plugin is, to put all the
53 hibernate-configuration in a <b>hibernate.properties</b>-file on your
54 classpath. Put the file in the <tt>resources</tt>-folder. Maven will put
55 it in the <tt>class</tt>-folder of your webapp, where it will be picked up
56 by this plugin as well as by Hibernate 4.
59 Doing so, the only additionally configuration needed, to activat the plugin
60 is the following entry in the <tt>plugins</tt>-section of your <tt>pom.xml</tt>:
62 <div class="prettyprint linenums lang-html"><pre>
64 <groupId>de.juplo</groupId>
65 <artifactId>hibernate-maven-plugin</artifactId>
66 <version>${project.version}</version>
70 <goal>export</goal>
74 </plugin></pre></div>
76 But be aware, that in this case the database-url, that is
77 build in the application is the same that is used while testing, where
78 the database is droped and recreated by the plugin.
81 you should never fire up this configuration on your production
82 system, or your database might be erased!
86 A better approach is, to specify a different url for testing like in the
89 <div class="prettyprint linenums lang-html"><pre>
91 <groupId>de.juplo</groupId>
92 <artifactId>hibernate-maven-plugin</artifactId>
93 <version>${project.version}</version>
97 <goal>export</goal>
101 <configuration>
102 <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
103 </configuration>
104 </plugin></pre></div>
106 Configuration properties, that are set in the <tt>configuration</tt>-section
107 of the plugin-configuration cannnot be overwritten elsewere (for details
108 see <a href="#precedence">Configuration-Method-Precedence</a>).
109 You never can overwrite them by accident when specifying a property on
110 the commandline or in your <tt>settings.xml</tt>.
112 </div><div class="section"><h2>Configuration through maven-properties<a name="Configuration_through_maven-properties"></a></h2>
114 Alternatively, it is possible, to configure the plugin via maven-properties.
115 Each relevant configuration-option has a corresponding maven-property
116 (for a full list see the <a href="./export-mojo.html">Documentation of the export-Mojo</a>).
117 These are named after the
118 <a class="externalLink" href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc">Hibernate JDBC Properties</a>:
121 <li><tt>hibernate.connection.driver_class</tt></li>
122 <li><tt>hibernate.dialect</tt></li>
123 <li><tt>hibernate.connection.url</tt></li>
124 <li><tt>hibernate.connection.username</tt></li>
125 <li><tt>hibernate.connection.password</tt></li>
128 So, instead of writing the hibernate-configuration in the properties-file,
129 like above, you could put it in the <tt>properties</tt>-section of your
133 Thogether with the plugin-definition from above, the following would
134 be a complete configuration (again, the database-url was overwritten in
135 the plugin-configuration, to be sure to have a separate database for
138 <div class="prettyprint linenums lang-html"><pre>
140 <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
141 <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
142 <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
143 <hibernate.connection.username>sa</hibernate.connection.username>
144 <hibernate.connection.password></hibernate.connection.password>
154 <groupId>de.juplo</groupId>
155 <artifactId>hibernate-maven-plugin</artifactId>
156 <version>${project.version}</version>
160 <goal>export</goal>
164 <configuration>
165 <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
166 </configuration>
169 <plugins></pre></div>
170 </div><div class="section"><h2>Configuration through the plugin-configuration<a name="Configuration_through_the_plugin-configuration"></a></h2>
172 A third way for configuring the plugin is the plugin-configuration.
173 The relevant configuration-parameters are:
176 <li><tt>driver</tt></li>
177 <li><tt>dialect</tt></li>
178 <li><tt>url</tt></li>
179 <li><tt>username</tt></li>
180 <li><tt>password</tt></li>
183 The equivalent of the configuration from the last section would look
186 <div class="prettyprint linenums lang-html"><pre>
188 <groupId>de.juplo</groupId>
189 <artifactId>hibernate-maven-plugin</artifactId>
190 <version>${project.version}</version>
194 <goal>export</goal>
198 <configuration>
199 <driver>org.hsqldb.jdbcDriver</driver>
200 <dialect>org.hibernate.dialect.HSQLDialect</dialect>
201 <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
202 <username>sa</username>
203 <password></password>
204 </configuration>
205 </plugin></pre></div>
207 The parameter <b>hibernateProperties</b> (name of the hibernate-properties-file
208 to use, defaults to <b>hibernate.properties</b>) can only be configured through
212 For more explanations, see the
213 <a href="./export-mojo.html">Documentation of the export-Mojo</a>.
215 </div><div class="section"><h2 id="precedence">Configuration-Method-Precedence</h2>
217 The configuration is gathered in a fix order:
219 <ol style="list-style-type: decimal">
220 <li><tt>hibernate.properties</tt></li>
221 <li><tt>hibernate.cfg.xml</tt></li>
222 <li><tt>persistence.xml</tt></li>
223 <li>maven-properties</li>
224 <li>plugin-configuration</li>
227 If you are in doubt about where a configuration-value comes from, run
228 maven with the <a href="./debugging.html">debug-output</a> enabled: <tt>mvn -X hibernate:export</tt>
229 and be aware, that maven-properties can be overwitten on the command-line,
230 in your <tt>~/.m2/settings.xml</tt> and in a profile.
233 The plugin-configuration comes last and overwrites everything else.
234 That way, you can be sure, that a configuration-value, that is
235 specified in the plugin-configuration will never be overwritten by any
236 other configuration-method.
239 If you need to overwrite plugin-configuration-values with
240 maven-properties, you can use maven-properties in the plugin-configuration:
242 <div class="prettyprint linenums lang-html"><pre>
244 <groupId>de.juplo</groupId>
245 <artifactId>hibernate-maven-plugin</artifactId>
246 <version>${project.version}</version>
250 <goal>export</goal>
254 <configuration>
255 <password>${my-password-property}</password>
256 </configuration>
257 </plugin></pre></div>
261 <div class="marginal">
264 <a id="navigation"></a>
265 <a class="hide" href="#top" title="Show Content">Jump back to the top of the page</a>
266 <h2 class="nav menu">Section-Menu</h2>
268 <li class="m blog"><a href="/blog/" class="m">Blog</a></li>
269 <li class="m projects"><a href="/projects.html" class="m selected">Projects</a></li>
270 <li class="m about"><a href="/about.html" class="m">About</a></li>
272 <h2 class="nav submenu">
273 <span class="s">Submenu for section</span>
274 <a class="s selected" href="/projects.html">Projects</a>
276 <ul id="submenu" class="s">
277 <li class="s sub off"><a class="s" href="/hibernate4-maven-plugin/">Hibernate 4 Maven Plugin</a></li>
282 <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
283 <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
290 <ul id="footerlinks">
291 <li class="f" id="copyright">© <strong>mo</strong> 2015
293 <li class="f"><a class="f" href="/impressum.html">Impressum</a></li>
294 <li class="f about"><a class="f" href="/about.html">About</a></li>
298 <script type="text/javascript"><!--//--><![CDATA[//><!--
299 var _gaq = _gaq || [];
300 _gaq.push(['_setAccount', 'UA-571104-3']);
301 _gaq.push(['_trackPageview']);
303 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
304 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
305 var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);