Redis Dev Service

When your application needs a Redis data store (such as when using Spring Data Redis or Spring AI Redis Vector Store), you can use the Redis Dev Service to automatically start a Redis server. This enables you to develop and test your application without having to manually start and manage the Redis server.

Dependencies

First, you need to add the Redis Dev Service dependency to your project. You can also include the Spring Boot DevTools dependency to enable live reload of your application during development.

dependencies {
  developmentOnly "org.springframework.boot:spring-boot-devtools"
  testAndDevelopmentOnly "io.arconia:arconia-dev-services-redis"
}
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

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). You can simply run your application using the usual tasks provided by the Spring Boot plugins for Gradle or Maven.

  • Gradle: ./gradlew bootRun

  • Maven: ./mvnw spring-boot:run

The Dev Service will automatically start when you run your application.

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

Choosing the Redis Edition

By default, the Redis Dev Service enables the Community Edition of Redis, but you can also activate the Stack Edition if you need to.

arconia:
  dev:
    services:
      redis:
        edition: stack

Customizing the Dev Service

You can customize the Dev Service via configuration properties, such as changing the image name or not reusing the service across multiple applications.

For Redis Community:

arconia:
  dev:
    services:
      redis:
        community:
          image-name: redis
          reusable: false

For Redis Stack:

arconia:
  dev:
    services:
      redis:
        stack:
          image-name: redis/redis-stack-server
          reusable: false

Disabling the Dev Service

If you want to disable the Dev Service, you can do so via configuration properties.

arconia:
  dev:
    services:
      redis:
        enabled: false
You can enable/disable the Dev Service for a specific test class by using the @TestProperty annotation or equivalent Spring testing utilities.
You can enable/disable the Dev Service for a specific application mode (development, test, production), relying on one of the profiles which are automatically configured by Arconia (see Profiles).