diff --git a/build.gradle.kts b/build.gradle.kts index 0e2a445..85be527 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,5 @@ +val exposedVersion: String by project + plugins { kotlin("jvm") version "2.0.10" kotlin("plugin.spring") version "2.0.10" @@ -23,6 +25,7 @@ dependencies { implementation("com.fasterxml.jackson.module:jackson-module-kotlin") implementation("org.jetbrains.kotlin:kotlin-reflect") + implementation("org.jetbrains.exposed:exposed-spring-boot-starter:$exposedVersion") runtimeOnly("com.mysql:mysql-connector-j") testImplementation("org.springframework.boot:spring-boot-starter-test") diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..308a206 --- /dev/null +++ b/gradle.properties @@ -0,0 +1 @@ +exposedVersion=0.56.0 diff --git a/src/main/kotlin/dev/kaistian/villagehall/config/ExposedConfig.kt b/src/main/kotlin/dev/kaistian/villagehall/config/ExposedConfig.kt new file mode 100644 index 0000000..ccd6e39 --- /dev/null +++ b/src/main/kotlin/dev/kaistian/villagehall/config/ExposedConfig.kt @@ -0,0 +1,20 @@ +package dev.kaistian.villagehall.config + +import org.jetbrains.exposed.spring.autoconfigure.ExposedAutoConfiguration +import org.jetbrains.exposed.sql.DatabaseConfig +import org.springframework.boot.autoconfigure.ImportAutoConfiguration +import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +@ImportAutoConfiguration( + value = [ExposedAutoConfiguration::class], + exclude = [DataSourceTransactionManagerAutoConfiguration::class] +) +class ExposedConfig { + @Bean + fun databaseConfig() = DatabaseConfig { + useNestedTransactions = true + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2eff4ef..7e85c8a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1 +1,8 @@ spring.application.name=kaist-village-hall + +spring.datasource.url=jdbc:mysql://localhost:3306/kaist_village_hall +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +spring.datasource.username=root +spring.datasource.password=password + +spring.exposed.show-sql=true