Skip to content

Commit

Permalink
refactor: 설정 코드 분리 및 패키지 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 committed Dec 5, 2024
1 parent c0545f8 commit ea5576d
Show file tree
Hide file tree
Showing 486 changed files with 2,043 additions and 4,792 deletions.
26 changes: 5 additions & 21 deletions api-repo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tasks.getByName("jar") {

dependencies {
/** module */
api(project(":data"))
implementation(project(":data"))

/** mysql */
implementation("com.mysql:mysql-connector-j")
Expand All @@ -17,27 +17,11 @@ dependencies {
api("org.springframework.boot:spring-boot-starter-jooq")
jooqCodegen("org.jooq:jooq-meta-extensions:${DependencyVersion.JOOQ}")

/** Local Cache **/
api("org.ehcache:ehcache:${DependencyVersion.EHCACHE}")
api("org.springframework.boot:spring-boot-starter-cache")

/** flyway */
implementation("org.flywaydb:flyway-core:${DependencyVersion.FLYWAY}")
implementation("org.flywaydb:flyway-mysql")

/** test container */
implementation(platform("org.testcontainers:testcontainers-bom:${DependencyVersion.TEST_CONTAINER}"))
testImplementation("org.testcontainers:mysql")

/** Local Cache **/
implementation("org.ehcache:ehcache:${DependencyVersion.EHCACHE}")
implementation("org.springframework.boot:spring-boot-starter-cache")
}

tasks {
test {
useJUnitPlatform()
}

register<Test>("generateExplainDocs") {
useJUnitPlatform {
includeTags("explain")
}
}
}
16 changes: 0 additions & 16 deletions api-repo/src/main/kotlin/com/few/api/repo/config/ApiRepoConfig.kt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.few.api.repo.common
package repo.common

import org.jooq.ExecuteContext
import org.jooq.ExecuteListener
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.few.api.repo.common
package repo.common

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jooq.ExecuteContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.few.api.repo.common
package repo.common

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jooq.ExecuteContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.few.api.repo.common
package repo.common

data class SlowQueryEvent(
val slowQuery: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.few.api.repo.config
package repo.config

import com.few.api.repo.common.ExceptionTranslator
import com.few.api.repo.common.NativeSQLLogger
import com.few.api.repo.common.PerformanceListener
import org.jooq.SQLDialect
import org.jooq.impl.DataSourceConnectionProvider
import org.jooq.impl.DefaultConfiguration
Expand All @@ -11,6 +8,9 @@ import org.springframework.context.ApplicationEventPublisher
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
import repo.common.ExceptionTranslator
import repo.common.NativeSQLLogger
import repo.common.PerformanceListener
import javax.sql.DataSource

@Configuration
Expand Down
13 changes: 13 additions & 0 deletions api-repo/src/main/kotlin/repo/config/RepoConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package repo.config

import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration

@Configuration
@ComponentScan(basePackages = [RepoConfig.BASE_PACKAGE])
class RepoConfig {
companion object {
const val BASE_PACKAGE = "repo"
const val BEAN_NAME_PREFIX = "repo"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.few.api.repo.datasource
package repo.datasource

import com.few.api.repo.config.ApiRepoConfig
import repo.config.RepoConfig
import com.zaxxer.hikari.HikariDataSource
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.jdbc.DataSourceBuilder
Expand All @@ -14,8 +14,8 @@ import javax.sql.DataSource
class DataSourceConfig {

companion object {
const val API_DATASOURCE = ApiRepoConfig.BEAN_NAME_PREFIX + "DataSource"
const val API_TX = ApiRepoConfig.BEAN_NAME_PREFIX + "TransactionManager"
const val API_DATASOURCE = RepoConfig.BEAN_NAME_PREFIX + "DataSource"
const val API_TX = RepoConfig.BEAN_NAME_PREFIX + "TransactionManager"
}

@Bean(name = [API_DATASOURCE])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.few.api.repo.flyway
package repo.flyway

import com.few.api.repo.config.ApiRepoConfig
import com.few.api.repo.datasource.DataSourceConfig
import repo.config.RepoConfig
import repo.datasource.DataSourceConfig
import org.flywaydb.core.Flyway
import org.flywaydb.core.api.configuration.FluentConfiguration
import org.springframework.beans.factory.annotation.Qualifier
Expand All @@ -18,35 +18,35 @@ import javax.sql.DataSource
@Configuration
@Import(DataSourceConfig::class)
class FlywayConfig {
@Bean(name = [ApiRepoConfig.BEAN_NAME_PREFIX + "Flyway"])
@Bean(name = [RepoConfig.BEAN_NAME_PREFIX + "Flyway"])
fun flyway(
configuration: org.flywaydb.core.api.configuration.Configuration?,
): Flyway {
return Flyway(configuration)
}

@Profile("!new")
@Bean(name = [ApiRepoConfig.BEAN_NAME_PREFIX + "FlywayValidateInitializer"])
@Bean(name = [RepoConfig.BEAN_NAME_PREFIX + "FlywayValidateInitializer"])
fun flywayValidateInitializer(
flyway: Flyway?,
): FlywayMigrationInitializer {
return FlywayMigrationInitializer(flyway) { obj: Flyway -> obj.validate() }
}

@Bean(name = [ApiRepoConfig.BEAN_NAME_PREFIX + "FlywayMigrationInitializer"])
@Bean(name = [RepoConfig.BEAN_NAME_PREFIX + "FlywayMigrationInitializer"])
fun flywayMigrationInitializer(
flyway: Flyway?,
): FlywayMigrationInitializer {
return FlywayMigrationInitializer(flyway) { obj: Flyway -> obj.migrate() }
}

@Bean(name = [ApiRepoConfig.BEAN_NAME_PREFIX + "FlywayProperties"])
@Bean(name = [RepoConfig.BEAN_NAME_PREFIX + "FlywayProperties"])
@ConfigurationProperties(prefix = "spring.flyway")
fun flywayProperties(): FlywayProperties {
return FlywayProperties()
}

@Bean(name = [ApiRepoConfig.BEAN_NAME_PREFIX + "FlywayConfiguration"])
@Bean(name = [RepoConfig.BEAN_NAME_PREFIX + "FlywayConfiguration"])
fun configuration(
@Qualifier(DataSourceConfig.API_DATASOURCE) dataSource: DataSource?,
): org.flywaydb.core.api.configuration.Configuration {
Expand Down

This file was deleted.

Loading

0 comments on commit ea5576d

Please sign in to comment.