PostgreSQL Dev Service
When your application needs a relational database (such as when using Spring Data JDBC or Spring Data JPA), you can use the Arconia PostgreSQL Dev Service to automatically start a PostgreSQL database. This enables you to develop and test your application without having to manually start and manage the database.
Dependencies
First, you need to add the Arconia PostgreSQL Dev Service dependency to your project.
dependencies {
testAndDevelopmentOnly 'io.arconia:arconia-dev-services-postgresql'
}
You can combine this with io.arconia:arconia-dev-tools , including the Spring Boot DevTools, which automatically restarts your application when you make changes to your code as part of your development workflow, while keeping the Dev Service up and running.
|
Running the Application
Unlike the lower-level Testcontainers support in Spring Boot, Arconia doesn’t require special tasks to run your application (./gradlew bootTestRun
or ./mvnw spring-boot:test-run
). You can simply use:
-
Gradle:
./gradlew bootRun
-
Maven:
./mvnw spring-boot:run
Your integration tests will automatically use the Arconia Dev Services without any additional configuration.
Whenever the application is reloaded via Spring Boot DevTools, the Dev Service will not be restarted. If you want to disable the live reload feature, you can do so by setting the spring.devtools.restart.enabled property to false . When doing so, the Dev Service will be shut down and restarted along with the application.
|
Customizing the Dev Service
You can customize the Dev Service via configuration properties, such as changing the image name or reusing the service across multiple applications and tests.
arconia:
dev:
services:
postgresql:
image-name: pgvector/pgvector:pg17
reusable: true
Disabling the Dev Service
If you want to disable the Dev Service, you can do so via configuration properties.
arconia:
dev:
services:
postgresql:
enabled: false
You can disable the Dev Service for a specific test class or method by using the @TestProperty annotation or equivalent Spring testing utilities.
|
Alternatively, you can disable it by excluding the auto-configuration class directly: PostgresqlDevServicesAutoConfiguration
.