This article covers a Bloomreach Experience Manager version 11. There's an updated version available that covers our most recent release.

Use MySQL in a Development Environment

Introduction

Goal

Set up your local Hippo development environment to use a MySQL database for storage.

Background

By default a Hippo project created from the Maven archetype is set up to use an embedded H2 database for storage. In some use cases you may want to use a different database, such as MySQL, during development. For production environments this is described at Configuring Hippo for MySQL. This page describes the additional steps required in a Cargo-based local development environment.

Prerequisites

This page assumes that your Hippo project and local development environment are set up following the Getting Started tutorial.

It also assumes that you have installed MySQL and created a database and a user with sufficient privileges (see Configuring Hippo for MySQL).

Add the MySQL Driver as a Dependency to Your POM

In the project's root pom.xml add the following dependency:

<dependencies>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.34</version>
      <scope>provided</scope>
    </dependency>
</dependencies>
Make sure this dependency is in the /project/dependencies section, not to be confused with the  /project/depencencyManagement/dependencies/ section!

Put the MySQL driver on the Cargo classpath

In the project's root pom.xml, locate the Cargo plugin configuration (in the cargo.run profile) and add the MySQL driver as a dependency to the container:

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <configuration>
    <container>
      <dependencies>
        <dependency>
          <groupId>mysql</groupId>
          <artifactId>mysql-connector-java</artifactId>
          <classpath>extra</classpath>
        </dependency>
      </dependencies>
    </container>
  </configuration>
</plugin>     
In the configuration snippet above some non-relevant configuration has been left out for clarity.

Register a MySQL DataSource with Tomcat

Add a Resource declaration to conf/context.xml. Use the example provided at Configuring Hippo for MySQL and subtitute your database details.

Create Custom Repository.xml

Add a file conf/repository.xml. Use the example provided at Configuring Hippo for MySQL.

Make the Repository Use the Custom Repository.xml

In the project's root pom.xml, locate the Cargo plugin configuration (in the cargo.run profile) and add the repo.config system property to system properties section of the container configuration:

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <configuration>
    <container>
      <systemProperties>
        <repo.config>file:${project.basedir}/conf/repository.xml</repo.config>
      </systemProperties>
    </container>
  </configuration>
</plugin>
In the configuration snippet above some non-relevant configuration has been left out for clarity.

Build and Run

Build and run your project as usual.

At the first startup the CMS webapp will create all required tables in the database.

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?