Skip to content

chapakook/SpringTestcontainers

Repository files navigation

Spring Testcontainers(SpringBoot 3.1+)

This is an example of configuring a MySQL integration test based on Testcontainers utilizing @ServiceConnection in Spring Boot 3.1+

📦 Project Spec Summary

✅ Language & Platform

  • Language: Kotlin 1.9.25
  • JVM Target: Java 21 (Toolchain)
  • Build Tool: Gradle (Kotlin DSL)
  • Spring Boot: 3.5.4

✅ Plugins

  • kotlin("jvm"): 1.9.25 - Kotlin → JVM compile
  • kotlin("plugin.spring"): 1.9.25 - Kotlin + Spring plugin
  • kotlin("plugin.jpa"): 1.9.25 - JPA entity no-arg/open plugin
  • org.springframework.boot: 3.5.4 - Spring Boot plugin
  • io.spring.dependency-management: 1.1.7 - dependency BOM and mangement

✅Dependencies

▶️ Spring Boot

  • org.springframework.boot:spring-boot-starter
  • org.springframework.boot:spring-boot-starter-data-jpa
  • org.springframework.boot:spring-boot-starter-test
  • org.springframework.boot:spring-boot-testcontainers

▶️ MySQL

  • com.mysql:mysql-connector-j

▶️ Testcontainers

  • org.testcontainers:mysql
  • org.junit.platform:junit-platform-launcher

▶️ Kotlin

  • org.jetbrains.kotlin:kotlin-reflect
  • org.jetbrains.kotlin:kotlin-test-junit5

📁 Project Directory Structure

.
├── main
│    ├── kotlin.com.chapakook.lab.springtestcontainers
│    │   ├── domain.user
│    │   │    ├── User.kt
│    │   │    └── UserRepository.kt
│    │   └── SpringTestcontainersApplication.kt
│    └── resources
│        └── application.yaml
└── com.chapakook.lab.springtestcontainers.domain.user
     ├── UserRepositoryTest.kt
     └── UserRepositoryTestWithServiceConnection.kt

⚙️ application.yaml

spring:
  application:
    name: service-connection
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages