MariaDB Dev Service

A service providing a MariaDB database for development and testing purposes.

It works with Spring Boot libraries that support MariaDB via JDBC, including:

Dependencies

First, you need to add the Dev Service dependency to your project.

  • Gradle

  • Maven

dependencies {
  testAndDevelopmentOnly "io.arconia:arconia-dev-services-mariadb"
}
<dependency>
    <groupId>io.arconia</groupId>
    <artifactId>arconia-dev-services-mariadb</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <includeOptional>false</includeOptional>
            </configuration>
        </plugin>
    </plugins>
</build>

You can optionally include the Spring Boot DevTools dependency to enable live reload of your application during development.

  • Gradle

  • Maven

dependencies {
  developmentOnly "org.springframework.boot:spring-boot-devtools"
}
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
    <optional>true</optional>
</dependency>

When you use the Spring Boot DevTools in your project, Arconia will keep the Dev Services running while you make changes to your code instead of restarting them with the application. This allows you to see the changes in real-time without having to restart the Dev Services.

Running the Application

When using the Arconia Dev Services, you can keep running your application as you normally would. The Dev Services will automatically start when you run your application.

  • CLI

  • Gradle

  • Maven

arconia dev
./gradlew bootRun
./mvnw spring-boot:run
Unlike the lower-level Testcontainers support in Spring Boot, Arconia doesn’t require special tasks to run your application when using Dev Services (./gradlew bootTestRun or ./mvnw spring-boot:test-run) nor requires you to define a separate @SpringBootApplication class for configuring Testcontainers.

Your integration tests will automatically use the Dev Services without any additional configuration.

Configuring the Dev Service

You can configure the Dev Service via configuration properties.

Property Default Description

arconia.dev.services.mariadb.enabled

true

Whether the dev service is enabled.

arconia.dev.services.mariadb.image-name

mariadb

Full name of the container image used in the dev service.

arconia.dev.services.mariadb.environment

{}

Environment variables to set in the container.

arconia.dev.services.mariadb.shared

never

When the dev service is shared across applications.

arconia.dev.services.mariadb.startup-timeout

120s

Maximum waiting time for the service to start.

arconia.dev.services.mariadb.username

test

Username to be used for connecting to the database.

arconia.dev.services.mariadb.password

test

Password to be used for connecting to the database.

arconia.dev.services.mariadb.db-name

test

Name of the database to be created.

arconia.dev.services.mariadb.init-script-paths

[]

List of paths to SQL scripts to be loaded from the classpath and applied to the database for initialization.

You can enable/disable the Dev Service selectively for a specific application mode (development, test), relying on one of the profiles which are automatically configured by Arconia (see Profiles).

You can enable/disable the Dev Service for a specific test class by using the @TestProperty annotation or equivalent Spring testing utilities.

Initializing the Database

You can initialize the database by providing one or more SQL scripts to be executed when the database is started. This can be useful for creating test data or applying other customizations that are only needed during development and testing.

If you need to create the database schema or apply other changes that are required also in production, you should use a database migration tool such as Flyway or Liquibase instead. They will also work automatically with Arconia Dev Services.

The scripts must be available in the application classpath, and you can specify their location using the arconia.dev.services.mariadb.init-script-paths property, which accepts a list of classpath locations.

For example, if you have a script named init.sql located in the src/main/resources/data directory of your project, you can configure the Dev Service to execute it when the database is started by adding the following property to your application.yml or application.properties file:

arconia.dev.services.mariadb.init-script-paths=classpath:data/init.sql

If you need to execute SQL scripts only when running tests, you can place them in the src/test/resources directory instead of src/main/resources.