Projekt-Dokumentation (Aktueller Stand von juplo.de) hinzugefĆ¼gt
[website] / dist / facebook-utils-2.5.0 / configuration.html
1 <!DOCTYPE html>
2 <!-- Generated by Apache Maven Doxia Site Renderer at Nov 10, 2015 -->
3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   <!-- Current: configuration.html -->
4 <!-- Active: index.html -->
5 <!-- Path: $path -->
6 <!-- Skiplist: [index.html, getting-started.html] -->
7 <html>
8   <head>
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;
16     </style>
17     <script src="/js/prettify.js"></script>
18     <!--[if lt IE 9]>
19       <script src="/js/html5shiv.js"></script>
20     <![endif]-->
21     <!--[if IE 8]>
22       <link rel="stylesheet" type="text/css" href="/css/ie8.css" />
23     <![endif]-->
24         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
25   </head>
26   <body class="menu" onload="prettyPrint()">
27     <div id="page" class="cf">
28       <header id="header">
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>
31         <hr class="h" />
32       </header>
33       <div id="breadcrumb">
34         <strong class="b title">You are here:</strong>
35         <ol class="b">
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>
40                   </ol>
41         <a class="hide" href="#navigation">Jump to navigation</a>
42         <hr class="b" />
43       </div>
44       <main class="content cf">
45         <article id="content" class="main">
46           <header><h1>$shortTitle</h1></header>
47           
48  
49  
50   <div class="section"><h2>Configuration through a hibernate.properties-File<a name="Configuration_through_a_hibernate.properties-File"></a></h2>
51   <p>
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.
57   </p>
58   <p>
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>:
61   </p>
62   <div class="prettyprint linenums lang-html"><pre>
63 &lt;plugin&gt;
64   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
65   &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
66   &lt;version&gt;${project.version}&lt;/version&gt;
67   &lt;executions&gt;
68     &lt;execution&gt;
69       &lt;goals&gt;
70         &lt;goal&gt;export&lt;/goal&gt;
71       &lt;/goals&gt;
72     &lt;/execution&gt;
73   &lt;/executions&gt;
74 &lt;/plugin&gt;</pre></div>
75   <p>
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.
79   Because of that,
80   <b>
81     you should never fire up this configuration on your production
82     system, or your database might be erased!
83   </b>
84   </p>
85   <p>
86   A better approach is, to specify a different url for testing like in the
87   following snippet:
88   </p>
89   <div class="prettyprint linenums lang-html"><pre>
90 &lt;plugin&gt;
91   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
92   &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
93   &lt;version&gt;${project.version}&lt;/version&gt;
94   &lt;executions&gt;
95     &lt;execution&gt;
96       &lt;goals&gt;
97         &lt;goal&gt;export&lt;/goal&gt;
98       &lt;/goals&gt;
99     &lt;/execution&gt;
100   &lt;/executions&gt;
101   &lt;configuration&gt;
102     &lt;url&gt;&lt;![CDATA[jdbc:mysql://localhost/test-db]]&gt;&lt;/url&gt;
103   &lt;/configuration&gt;
104 &lt;/plugin&gt;</pre></div>
105   <p>
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>.
111   </p>
112   </div><div class="section"><h2>Configuration through maven-properties<a name="Configuration_through_maven-properties"></a></h2>
113   <p>
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>:
119   </p>
120   <ul>
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>
126   </ul>
127   <p>
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
130   <tt>pom.xml</tt>.
131   </p>
132   <p>
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
136   testing):
137   </p>
138   <div class="prettyprint linenums lang-html"><pre>
139 &lt;properties&gt;
140   &lt;hibernate.connection.driver_class&gt;org.hsqldb.jdbcDriver&lt;/hibernate.connection.driver_class&gt;
141   &lt;hibernate.dialect&gt;org.hibernate.dialect.HSQLDialect&lt;/hibernate.dialect&gt;
142   &lt;hibernate.connection.url&gt;&lt;![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]&gt;&lt;/hibernate.connection.url&gt;
143   &lt;hibernate.connection.username&gt;sa&lt;/hibernate.connection.username&gt;
144   &lt;hibernate.connection.password&gt;&lt;/hibernate.connection.password&gt;
145 &lt;/properties&gt;
146
147 ...
148
149 &lt;plugins&gt;
150
151   ...
152
153   &lt;plugin&gt;
154     &lt;groupId&gt;de.juplo&lt;/groupId&gt;
155     &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
156     &lt;version&gt;${project.version}&lt;/version&gt;
157     &lt;executions&gt;
158       &lt;execution&gt;
159         &lt;goals&gt;
160           &lt;goal&gt;export&lt;/goal&gt;
161         &lt;/goals&gt;
162       &lt;/execution&gt;
163     &lt;/executions&gt;
164     &lt;configuration&gt;
165       &lt;url&gt;&lt;![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]&gt;&lt;/url&gt;
166     &lt;/configuration&gt;
167   &lt;/plugin&gt;
168
169 &lt;plugins&gt;</pre></div>
170   </div><div class="section"><h2>Configuration through the plugin-configuration<a name="Configuration_through_the_plugin-configuration"></a></h2>
171   <p>
172   A third way for configuring the plugin is the plugin-configuration.
173   The relevant configuration-parameters are:
174   </p>
175   <ul>
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>
181   </ul>
182   <p>
183   The equivalent of the configuration from the last section would look
184   like this:
185   </p>
186   <div class="prettyprint linenums lang-html"><pre>
187 &lt;plugin&gt;
188   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
189   &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
190   &lt;version&gt;${project.version}&lt;/version&gt;
191   &lt;executions&gt;
192     &lt;execution&gt;
193       &lt;goals&gt;
194         &lt;goal&gt;export&lt;/goal&gt;
195       &lt;/goals&gt;
196     &lt;/execution&gt;
197   &lt;/executions&gt;
198   &lt;configuration&gt;
199     &lt;driver&gt;org.hsqldb.jdbcDriver&lt;/driver&gt;
200     &lt;dialect&gt;org.hibernate.dialect.HSQLDialect&lt;/dialect&gt;
201     &lt;url&gt;&lt;![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]&gt;&lt;/url&gt;
202     &lt;username&gt;sa&lt;/username&gt;
203     &lt;password&gt;&lt;/password&gt;
204   &lt;/configuration&gt;
205 &lt;/plugin&gt;</pre></div>
206   <p>
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
209   this approach.
210   </p>
211   <p>
212   For more explanations, see the
213   <a href="./export-mojo.html">Documentation of the export-Mojo</a>.
214   </p>
215   </div><div class="section"><h2 id="precedence">Configuration-Method-Precedence</h2>
216   <p>
217   The configuration is gathered in a fix order:
218   </p>
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>
225   </ol>
226   <p>
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.
231   </p>
232   <p>
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.
237   </p>
238   <p>
239   If you need to overwrite plugin-configuration-values with
240   maven-properties, you can use maven-properties in the plugin-configuration:
241   </p>
242   <div class="prettyprint linenums lang-html"><pre>
243 &lt;plugin&gt;
244   &lt;groupId&gt;de.juplo&lt;/groupId&gt;
245   &lt;artifactId&gt;hibernate-maven-plugin&lt;/artifactId&gt;
246   &lt;version&gt;${project.version}&lt;/version&gt;
247   &lt;executions&gt;
248     &lt;execution&gt;
249       &lt;goals&gt;
250         &lt;goal&gt;export&lt;/goal&gt;
251       &lt;/goals&gt;
252     &lt;/execution&gt;
253   &lt;/executions&gt;
254   &lt;configuration&gt;
255     &lt;password&gt;${my-password-property}&lt;/password&gt;
256   &lt;/configuration&gt;
257 &lt;/plugin&gt;</pre></div>
258  </div>
259
260         </article>
261         <div class="marginal">
262           <nav id="nav">
263             <hr class="n" />
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>
267             <ul id="menu">
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>
271             </ul>
272             <h2 class="nav submenu">
273               <span class="s">Submenu for section</span>
274               <a class="s selected" href="/projects.html">Projects</a>
275             </h2>
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>
278                                           </ul>
279             <hr class="n" />
280           </nav>
281           <aside class="m">
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" />
284             </a>
285           </aside>
286         </div>
287       </main>
288       <footer id="footer">
289         <hr class="f" />
290         <ul id="footerlinks">
291           <li class="f" id="copyright">&#xa9; <strong>mo</strong>             2015
292       </li>
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>
295         </ul>
296       </footer>
297     </div>
298         <script type="text/javascript"><!--//--><![CDATA[//><!--
299       var _gaq = _gaq || [];
300       _gaq.push(['_setAccount', 'UA-571104-3']);
301       _gaq.push(['_trackPageview']);
302       (function() {
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);
306       })();
307     //--><!]]>
308     </script>
309       </body>
310 </html>