+++ /dev/null
-<!DOCTYPE html>
-<!-- Generated by Apache Maven Doxia Site Renderer 1.4 at 2014-11-11 -->
- <!-- Current: configuration.html -->
-<!-- Active: index.html -->
-<!-- Path: [index.html, configuration.html] -->
-<!-- Skiplist: [index.html, configuration.html, export-mojo.html, debugging.html, skip.html, force.html, pitfalls.html] -->
-<html>
- <head>
- <title>juplo - Hibernate 4 Maven Plugin - Configuration Examples</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="canonical" href="http://juplo.de/hibernate4-maven-plugin/configuration.html"/>
- <meta name="viewport" content="width=device-width, initial-scale=1" />
- <link rel="stylesheet" type="text/css" href="/css/base.css" />
- <style type="text/css">
- @import '/css/screen.css' screen;
- </style>
- <script src="/js/base.js"></script>
- <!--[if IE 8]>
- <link rel="stylesheet" type="text/css" href="/css/ie8.css" />
- <script src="/js/ie8.js"></script>
- <![endif]-->
- <!--[if IE 7]>
- <script src="/js/ie7.js"></script>
- <![endif]-->
- <!--[if lt IE 7]>
- <script src="/js/ie6.js"></script>
- <![endif]-->
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- </head>
- <body class="menu" onload="prettyPrint()">
- <div id="page" class="cf">
- <header id="header">
- <h1 id="logo"><a href="/" title="Home" class="l">juplo</a></h1>
- <span id="slogan"><strong>Java</strong> bits from nerds for nerds</span>
- <hr class="h" />
- </header>
- <div id="breadcrumb">
- <strong class="b title">You are here:</strong>
- <ol class="b">
- <li class="b"><a class="b" href="/">Home</a></li>
- <li class="b"><a class="b" href="/projects.html">Projects</a></li>
- <li class="b"><a class="b" href="./index.html">Hibernate 4 Maven Plugin</a></li>
- <li class="b"><strong class="b">Configuration Examples</strong></li>
- </ol>
- <a class="hide" href="#navigation">Jump to navigation</a>
- <hr class="b" />
- </div>
- <main class="content cf">
- <article id="content" class="main">
- <header><h1>Configuration Examples</h1></header>
-
-
-
-
-<div class="section">
-<h2>Configuration through a hibernate.properties-File<a name="Configuration_through_a_hibernate.properties-File"></a></h2>
-
-<p>
- The most simple way to configure the plugin is, to put all the
- hibernate-configuration in a <b>hibernate.properties</b>-file on your
- classpath. Put the file in the <tt>resources</tt>-folder. Maven will put
- it in the <tt>class</tt>-folder of your webapp, where it will be picked up
- by this plugin as well as by Hibernate 4.
- </p>
-
-<p>
- Doing so, the only additionally configuration needed, to activat the plugin
- is the following entry in the <tt>plugins</tt>-section of your <tt>pom.xml</tt>:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate4-maven-plugin</artifactId>
- <version>1.0.5</version>
- <executions>
- <execution>
- <goals>
- <goal>export</goal>
- </goals>
- </execution>
- </executions>
-</plugin></pre></div>
-
-<p>
- But be aware, that in this case the database-url, that is
- build in the application is the same that is used while testing, where
- the database is droped and recreated by the plugin.
- Because of that,
- <b>
- you should never fire up this configuration on your production
- system, or your database might be erased!
- </b>
- </p>
-
-<p>
- A better approach is, to specify a different url for testing like in the
- following snippet:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate4-maven-plugin</artifactId>
- <version>1.0.5</version>
- <executions>
- <execution>
- <goals>
- <goal>export</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <url><![CDATA[jdbc:mysql://localhost/test-db]]></url>
- </configuration>
-</plugin></pre></div>
-
-<p>
- Configuration properties, that are set in the <tt>configuration</tt>-section
- of the plugin-configuration cannnot be overwritten elsewere (for details
- see <a href="#precedence">Configuration-Method-Precedence</a>).
- You never can overwrite them by accident when specifying a property on
- the commandline or in your <tt>settings.xml</tt>.
- </p>
- </div>
-<div class="section">
-<h2>Configuration through maven-properties<a name="Configuration_through_maven-properties"></a></h2>
-
-<p>
- Alternatively, it is possible, to configure the plugin via maven-properties.
- Each relevant configuration-option has a corresponding maven-property
- (for a full list see the <a href="./export-mojo.html">Documentation of the export-Mojo</a>).
- These are named after the
- <a class="externalLink" href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#configuration-hibernatejdbc">Hibernate JDBC Properties</a>:
- </p>
-
-<ul>
-
-<li><tt>hibernate.connection.driver_class</tt></li>
-
-<li><tt>hibernate.dialect</tt></li>
-
-<li><tt>hibernate.connection.url</tt></li>
-
-<li><tt>hibernate.connection.username</tt></li>
-
-<li><tt>hibernate.connection.password</tt></li>
- </ul>
-
-<p>
- So, instead of writing the hibernate-configuration in the properties-file,
- like above, you could put it in the <tt>properties</tt>-section of your
- <tt>pom.xml</tt>.
- </p>
-
-<p>
- Thogether with the plugin-definition from above, the following would
- be a complete configuration (again, the database-url was overwritten in
- the plugin-configuration, to be sure to have a separate database for
- testing):
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<properties>
- <hibernate.connection.driver_class>org.hsqldb.jdbcDriver</hibernate.connection.driver_class>
- <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
- <hibernate.connection.url><![CDATA[jdbc:hsqldb:res:org.my.path.production_db]]></hibernate.connection.url>
- <hibernate.connection.username>sa</hibernate.connection.username>
- <hibernate.connection.password></hibernate.connection.password>
-</properties>
-
-...
-
-<plugins>
-
- ...
-
- <plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate4-maven-plugin</artifactId>
- <version>1.0.5</version>
- <executions>
- <execution>
- <goals>
- <goal>export</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <url><![CDATA[jdbc:hsqldb:target/db/testdb;shutdown=true]]></url>
- </configuration>
- </plugin>
-
-<plugins></pre></div>
- </div>
-<div class="section">
-<h2>Configuration through the plugin-configuration<a name="Configuration_through_the_plugin-configuration"></a></h2>
-
-<p>
- A third way for configuring the plugin is the plugin-configuration.
- The relevant configuration-parameters are:
- </p>
-
-<ul>
-
-<li><tt>driverClassName</tt></li>
-
-<li><tt>hibernateDialect</tt></li>
-
-<li><tt>url</tt></li>
-
-<li><tt>username</tt></li>
-
-<li><tt>password</tt></li>
- </ul>
-
-<p>
- The equivalent of the configuration from the last section would look
- like this:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate4-maven-plugin</artifactId>
- <version>1.0.5</version>
- <executions>
- <execution>
- <goals>
- <goal>export</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <driverClassName>org.hsqldb.jdbcDriver</driverClassName>
- <hibernateDialect>org.hibernate.dialect.HSQLDialect</hibernateDialect>
- <url><![CDATA[jdbc:hsqldb:target/db/fotos;shutdown=true]]></url>
- <username>sa</username>
- <password></password>
- </configuration>
-</plugin></pre></div>
-
-<p>
- The parameter <b>hibernateProperties</b> (name of the hibernate-properties-file
- to use, defaults to <b>hibernate.properties</b>) can only be configured through
- this approach.
- </p>
-
-<p>
- For more explanations, see the
- <a href="./export-mojo.html">Documentation of the export-Mojo</a>.
- </p>
- </div>
-<div class="section" id="precedence">
-<h2 id="precedence">Configuration-Method-Precedence</h2>
-
-<p>
- The configuration is gathered in a fix order:
- </p>
-
-<ol style="list-style-type: decimal">
-
-<li><tt>hibernate.properties</tt></li>
-
-<li>maven-properties</li>
-
-<li>plugin-configuration</li>
- </ol>
-
-<p>
- If you are in doubt about where a configuration-value comes from, run
- maven with the <a href="./debugging.html">debug-output</a> enabled: <tt>mvn -X hibernate4:export</tt>
- and be aware, that maven-properties can be overwitten on the command-line,
- in your <tt>~/.m2/settings.xml</tt> and in a profile.
- </p>
-
-<p>
- The plugin-configuration comes last and overwrites everything else.
- That way, you can be sure, that a configuration-value, that is
- specified in the plugin-configuration will never be overwritten by any
- other configuration-method.
- </p>
-
-<p>
- If you need to overwrite plugin-configuration-values with
- maven-properties, you can use maven-properties in the plugin-configuration:
- </p>
-
-<div>
-<pre class="prettyprint linenums lang-html">
-<plugin>
- <groupId>de.juplo</groupId>
- <artifactId>hibernate4-maven-plugin</artifactId>
- <version>1.0.5</version>
- <executions>
- <execution>
- <goals>
- <goal>export</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <password>${my-password-property}</password>
- </configuration>
-</plugin></pre></div>
- </div>
-
- </article>
- <div class="marginal">
- <nav id="nav">
- <hr class="n" />
- <a id="navigation"></a>
- <a class="hide" href="#top" title="Show Content">Jump back to the top of the page</a>
- <h2 class="nav menu">Section-Menu</h2>
- <ul id="menu">
- <li class="m blog"><a href="/blog/" class="m">Blog</a></li>
- <li class="m projects"><a href="/projects.html" class="m selected">Projects</a></li>
- <li class="m about"><a href="/about.html" class="m">About</a></li>
- </ul>
- <h2 class="nav submenu">
- <span class="s">Submenu for section</span>
- <a class="s selected" href="/projects.html">Projects</a>
- </h2>
- <ul id="submenu" class="s">
- <li class="s sub">
- <a class="s selected" href="./index.html">Hibernate 4 Maven Plugin</a>
- <ul class="s active">
- <li class="s">
- <strong class="s">Configuration Examples</strong>
- </li>
- <li class="s">
- <a href="export-mojo.html" class="s" title="Parameter Documentation">Parameter Documentation</a>
- </li>
- <li class="s">
- <a href="debugging.html" class="s" title="Enable Debug-Output">Enable Debug-Output</a>
- </li>
- <li class="s">
- <a href="skip.html" class="s" title="Skipping Execution">Skipping Execution</a>
- </li>
- <li class="s">
- <a href="force.html" class="s" title="Force Exceution">Force Exceution</a>
- </li>
- <li class="s">
- <a href="pitfalls.html" class="s" title="Known Pitfalls (FAQ)">Known Pitfalls (FAQ)</a>
- </li>
- <li class="s sub">
- <a href="project-info.html" class="s" title="Project Information">Project Information</a>
- </li>
- <li class="s sub">
- <a href="project-reports.html" class="s" title="Project Reports">Project Reports</a>
- </li>
- </ul>
- </li>
- </ul>
- <hr class="n" />
- </nav>
- <aside class="m">
- <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
- <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
- </a>
- </aside>
- </div>
- </main>
- <footer id="footer">
- <hr class="f" />
- <ul id="footerlinks">
- <li class="f" id="copyright">© <strong>mo</strong> 2014
- </li>
- <li class="f"><a class="f" href="/impressum.html">Impressum</a></li>
- <li class="f about"><a class="f" href="/about.html">About</a></li>
- </ul>
- </footer>
- </div>
- <script type="text/javascript"><!--//--><![CDATA[//><!--
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', 'UA-571104-3']);
- _gaq.push(['_trackPageview']);
- (function() {
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
- })();
- //--><!]]>
- </script>
- </body>
-</html>