{"id":37425256,"url":"https://github.com/cloudflightio/springboot-testresources","last_synced_at":"2026-01-16T06:12:42.592Z","repository":{"id":103260141,"uuid":"585586074","full_name":"cloudflightio/springboot-testresources","owner":"cloudflightio","description":"Spring Boot Test Resources powered by TestContainers and Micronaut","archived":false,"fork":false,"pushed_at":"2025-12-19T09:30:48.000Z","size":145,"stargazers_count":23,"open_issues_count":1,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-12-21T18:34:25.820Z","etag":null,"topics":["micronaut","spring-boot","tdd","testcontainers"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cloudflightio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-05T14:50:56.000Z","updated_at":"2025-12-21T09:43:52.000Z","dependencies_parsed_at":"2023-03-07T17:15:24.301Z","dependency_job_id":null,"html_url":"https://github.com/cloudflightio/springboot-testresources","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/cloudflightio/springboot-testresources","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflightio%2Fspringboot-testresources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflightio%2Fspringboot-testresources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflightio%2Fspringboot-testresources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflightio%2Fspringboot-testresources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloudflightio","download_url":"https://codeload.github.com/cloudflightio/springboot-testresources/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloudflightio%2Fspringboot-testresources/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["micronaut","spring-boot","tdd","testcontainers"],"created_at":"2026-01-16T06:12:40.556Z","updated_at":"2026-01-16T06:12:42.579Z","avatar_url":"https://github.com/cloudflightio.png","language":"Java","readme":"# Spring Boot TestResources\n\n[![License](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Maven Central](https://img.shields.io/maven-central/v/io.cloudflight.testresources.springboot/springboot-testresources-client.svg?label=Maven%20Central)](https://search.maven.org/artifact/io.cloudflight.testresources.springboot/springboot-testresources-client)\n\nThis project is a POC to combine [Micronaut's Test Resources](https://micronaut-projects.github.io/micronaut-test-resources/latest/guide/) project with Spring Boot.\nThe project is still in very early stage and subject to bigger changes.\n\n# Concept\n\n[TestContainers](https://www.testcontainers.org/) is a great framework for testing your application code against infrastructure\ncomponents like databases, message brokers and so forth. If you are developing [Spring Boot](https://spring.io/projects/spring-boot)\napplications, the [PlayTika TestContainers library](https://github.com/PlaytikaOSS/testcontainers-spring-boot/) is a helpful assistent\nto connect your Spring Application context with the TestContainers.\n\nMicronaut released a sub-project called [Test Resources](https://micronaut-projects.github.io/micronaut-test-resources/latest/guide/) which \nalso comes with TestContainers under the hood but it provides a [test resources server](https://micronaut-projects.github.io/micronaut-test-resources/latest/guide/#architecture-server)\nwhich takes care of provisioning your containers during the build. This server can run standalone and \ncan therefore survive independent builds and keep your containers alive. This in turn can significantly\nreduce your build times.\n\nThis library combines those two approaches by implementing instances of [TestResourcesResolver](https://micronaut-projects.github.io/micronaut-test-resources/latest/guide/#implementing-test-resources), mapping\nto the default properties of Spring Boot, i.e. `spring.datasource.url`. A special `PropertySource` fetches the properties\nfrom the resource server.\n\nThat way, together with the build plugins from Micronaut for Gradle and Maven, you can **easily test \nyour Spring Boot applications using Micronaut Test Resources and TestContainers** and benefit\nfrom keeping your containers alive during builds.\n\n# How it works\n\nThis library consists of two parts: \n\n* a thin client layer to be packaged with your Spring Boot application (for test cases) which configures your ApplicationContext\n* plugins for the test resources server for the various modules (MariaDB, MinIO) which configure the containers based on Spring Boot properties\n\nFollow the following steps, to get it running:\n\nFirst thing is to add the [Gradle Plugin](https://micronaut-projects.github.io/micronaut-gradle-plugin/latest/#test-resources) to your build. If you use Maven,\nplease consult the [official documentation](https://micronaut-projects.github.io/micronaut-maven-plugin/latest/examples/test-resources.html).\n\nGo to your `build.gradle.kts`: \n\n````kotlin\nplugins {\n    id(\"io.micronaut.test-resources\") version \"3.7.7\"\n}\n````\n\nIn multi-module projects ensure that the plugin is applied on every module (especially on the one which is holding your Spring Boot application tests).\n\nThen, add this to your `gradle.properties`:\n\n````properties\nmicronautVersion=3.8.7\n````\n\nNext thing is to go to the module which contains your Spring Boot application \nand your `@SpringBootTest` and add the module `springboot-testresources-client` to the test-scope in your `build.gradle.kts`:\n\n````kotlin\ndependencies {\n    testRuntimeOnly(\"io.cloudflight.testresources.springboot:springboot-testresources-client:0.0.2\")\n}\n````\n\nWe strongly recommend to use `testRuntimeOnly` instead of `testImplementation` in order to avoid having Micronaut\non your implementation classpath.\n\nThen, as a last step, you need to add one or more of our test modules to the `testResourcesImplementation` scope, which \nhas been created by the Micronaut Test Resources plugin.\n\nSuppose you need a container for MariaDB, then add the following line:\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-jdbc-mariadb:0.0.2\")\n}\n````\n\nThat's it. You can now run your `@SpringBootTest`. \n\n## Full example\n\nTo give you an even better overview, here is a full example of a minimalistic Spring Boot application with Spring Data + MariaDB.\n\n`build.gradle.kts`\n\n````kotlin\nplugins {\n    id(\"io.cloudflight.autoconfigure-gradle\") version \"0.9.4\"\n    id(\"io.micronaut.test-resources\") version \"3.7.7\"\n}\n\nversion = \"0.1\"\ngroup = \"io.cloudflight\"\n\nrepositories {\n    mavenCentral()\n}\n\nautoConfigure {\n    java {\n        languageVersion.set(JavaLanguageVersion.of(17))\n    }\n}\n\ndependencies {\n    implementation(\"org.springframework.boot:spring-boot-starter-data-jpa:3.0.1\")\n    runtimeOnly(\"org.jetbrains.kotlin:kotlin-reflect\")\n\n    testImplementation(\"org.springframework.boot:spring-boot-starter-test:3.0.1\")\n\n    runtimeOnly(\"org.mariadb.jdbc:mariadb-java-client:3.0.6\")\n\n    testImplementation(\"org.junit.jupiter:junit-jupiter-api:5.8.1\")\n    testRuntimeOnly(\"org.junit.jupiter:junit-jupiter-engine:5.8.1\")\n    testRuntimeOnly(\"io.cloudflight.testresources.springboot:springboot-testresources-client:0.0.2\")\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-jdbc-mariadb:0.0.2\")\n}\n````\n\nThen, create a `src/main/kotlin/io/cloudflight/Application.kt`\n\n````kotlin\npackage io.cloudflight\n\nimport jakarta.persistence.Entity\nimport jakarta.persistence.GeneratedValue\nimport jakarta.persistence.Id\nimport org.springframework.boot.autoconfigure.SpringBootApplication\nimport org.springframework.boot.runApplication\nimport org.springframework.data.jpa.repository.JpaRepository\n\n@SpringBootApplication\nclass Application\n\nfun main(vararg args: String) {\n    runApplication\u003cApplication\u003e(args)\n}\n\n@Entity\nclass Person(var name: String) {\n\n    @Id\n    @GeneratedValue\n    var id: Long = 0\n}\n\ninterface PersonRepository : JpaRepository\u003cPerson, Long\u003e\n````\n\nConfigure the application to create a database on startup with Hibernate Auto-DDL in `src/main/resources/application.yaml`:\n\n````yaml\nspring:\n  jpa:\n    hibernate:\n      ddl-auto: create-drop\n````\n\nAnd finally, create a `src/test/kotlin/io/cloudflight/ApplicationTest.kt`:\n\n````kotlin\npackage io.cloudflight\n\nimport org.junit.jupiter.api.Test\nimport org.springframework.beans.factory.annotation.Autowired\nimport org.springframework.boot.test.context.SpringBootTest\n\n@SpringBootTest\nclass ApplicationTest(\n    @Autowired private val repository: PersonRepository\n) {\n\n    @Test\n    fun enterData() {\n        repository.save(Person(name = \"Klaus\"))\n    }\n}\n````\n\nIf you now run the test, the following happens:\n\n1. The Micronaut Test Resources starts the test resources server which can handle requests to configure a MariaDB docker container\n2. The `ApplicationTest` picks up the [TestResourcesEnvironmentPostProcessor](https://github.com/cloudflightio/springboot-testresources/blob/master/springboot-testresources-client/src/main/java/io/cloudflight/testresources/springboot/client/TestResourcesEnvironmentPostProcessor.java) which uses the [TestResourcesPropertySource](https://github.com/cloudflightio/springboot-testresources/blob/master/springboot-testresources-client/src/main/java/io/cloudflight/testresources/springboot/client/TestResourcesPropertySource.java) to automatically configure properties like `spring.datasource.url` or `spring.datasource.username` based on the settings from the docker container.\n3. The [MariaDbTestResourcesProvider](https://github.com/cloudflightio/springboot-testresources/blob/master/springboot-testresources-jdbc-mariadb/src/main/java/io/cloudflight/testresources/springboot/MariaDbTestResourcesProvider.java) starts the `MariaDBContainer` from the TestContainers project\n4. The `ApplicationTest` connects its `PersonRepository` to exactly that database and can insert data to the DB.\n\nAs you see, we did not have to configure properties like `spring.datasource.url` manually, that was all provided automatically.\n\n\n# Requirements\n\nSpring Boot Test Resources is compatible with Spring Boot 3.x but also with 2.7. \nIt requires a JDK 17 (we could also easily publish it for JDK 11 or below, but we want you to push towards the latest LTS)\n\nAdditionally, you need a plugin to start the test resources server. We have tested our library with the Micronaut Test Resources [Gradle Plugin](https://micronaut-projects.github.io/micronaut-gradle-plugin/latest/#test-resources), but it should also work fine for [Maven](https://micronaut-projects.github.io/micronaut-maven-plugin/latest/examples/test-resources.html).\n\n\n# Modules\n\nWe currently only provide some few modules, as this library is still in a PoC phase, but the number of modules will grow over time.\n\n## Common configuration\n\nFor each module you can override the default image which is being pulled by adding \n\n````yaml\ntest-resources:\n  containers:\n    mariadb:\n      image-name: mariadb:10.3\n````\n\nYou can also always override any of the provided properties by adding any of those properties below `test-resources.containers.mariadb`. For example,\nif you want to use another `username` than the default one, you can add:\n\n````yaml\ntest-resources:\n  containers:\n    mariadb:\n      image-name: mariadb:10.3\n      username: myusername\n````\n\nThis will create a MariaDB container based on `mariadb:10.3` with the default username `myusername`.\n\n## MariaDB\n\n* **Module-ID**: mariadb\n* **Default-Image**: mariadb\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-jdbc-mariadb:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.datasource.url`\n  * `spring.datasource.username`\n  * `spring.datasource.password`\n  * `spring.datasource.driver-class-name`\n\n## Microsoft SQL Server\n\n### MSSQL specific:\nMake sure to add the following property to your ```application-test.yml``` to accept the MSSQL Server License Agreement:\n```yml\ntest-resources:\n  containers:\n    mssql:\n      accept-license: true\n```\n\n* **Module-ID**: mssql\n* **Default-Image**: mcr.microsoft.com/mssql/server:2019-CU16-GDR1-ubuntu-20.04\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-jdbc-mssql:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.datasource.url`\n  * `spring.datasource.username`\n  * `spring.datasource.password`\n  * `spring.datasource.driver-class-name`\n\n## Postgres\n\n* **Module-ID**: postgres\n* **Default-Image**: postgres\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-jdbc-postgres:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.datasource.url`\n  * `spring.datasource.username`\n  * `spring.datasource.password`\n  * `spring.datasource.driver-class-name`\n\n\n## MinIO\n\n* **Module-ID**: minio\n* **Default-Image**: minio/minio\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-minio:0.2.1\")\n}\n````\n\n* **Provided properties**:\n    * `minio.url`\n    * `minio.access-key`\n    * `minio.secret-key`\n    * `minio.region`\n\n## RabbitMQ\n\n* **Module-ID**: rabbitmq\n* **Default-Image**: rabbitmq\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-rabbitmq:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.rabbitmq.host`\n  * `spring.rabbitmq.port`\n  * `spring.rabbitmq.username`\n  * `spring.rabbitmq.password`\n\n## Redis\n\n* **Module-ID**: redis\n* **Default-Image**: redis\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-redis:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.data.redis.url`\n\n## Azurite\n\n* **Module-ID**: azurite\n* **Default-Image**: mcr.microsoft.com/azure-storage/azurite\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-azurite:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.cloud.azure.storage.blob.account-name`\n  * `spring.cloud.azure.storage.blob.account-key`\n  * `spring.cloud.azure.storage.blob.endpoint`\n\n## Mailhog\n\n* **Module-ID**: mailhog\n* **Default-Image**: mailhog/mailhog\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-mailhog:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.mail.host`\n  * `spring.mail.port`\n  * `test-resources.mailhog.api-url`\n\n## Elasticsearch\n\n* **Module-ID**: elasticsearch\n* **Default-Image**: docker.elastic.co/elasticsearch/elasticsearch\n\n````kotlin\ndependencies {\n    testResourcesImplementation (\"io.cloudflight.testresources.springboot:springboot-testresources-elasticsearch:0.2.1\")\n}\n````\n\n* **Provided properties**:\n  * `spring.elasticsearch.uris`\n  * `spring.elasticsearch.password`","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudflightio%2Fspringboot-testresources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloudflightio%2Fspringboot-testresources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloudflightio%2Fspringboot-testresources/lists"}