File tree Expand file tree Collapse file tree 6 files changed +77
-1
lines changed
kotlin/com/wafflestudio/team2server/config
kotlin/com/wafflestudio/team2server Expand file tree Collapse file tree 6 files changed +77
-1
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ dependencies {
4242 testImplementation(" org.springframework.boot:spring-boot-starter-data-jdbc-test" )
4343 testImplementation(" org.springframework.boot:spring-boot-starter-flyway-test" )
4444 testImplementation(" org.springframework.boot:spring-boot-starter-webmvc-test" )
45- testImplementation(" org.jetbrains.kotlin:kotlin-test-junit5" )
45+ testImplementation(" org.testcontainers:junit-jupiter:1.21.4" )
46+ testImplementation(" org.testcontainers:mysql:1.21.4" )
4647 testRuntimeOnly(" org.junit.platform:junit-platform-launcher" )
4748}
4849
Original file line number Diff line number Diff line change 1+ package com.wafflestudio.team2server.config
2+
3+ import org.springframework.boot.jdbc.DataSourceBuilder
4+ import org.springframework.context.annotation.Bean
5+ import org.springframework.context.annotation.Configuration
6+ import org.springframework.core.env.Environment
7+ import org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration
8+ import org.springframework.data.jdbc.repository.config.EnableJdbcAuditing
9+ import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories
10+ import javax.sql.DataSource
11+
12+ @Configuration
13+ @EnableJdbcRepositories(basePackages = [" com.wafflestudio.team2server" ])
14+ @EnableJdbcAuditing
15+ class DatabaseConfig (
16+ private val env : Environment ,
17+ ) : AbstractJdbcConfiguration() {
18+ @Bean
19+ fun dataSource (): DataSource =
20+ DataSourceBuilder
21+ .create()
22+ .url(env.getProperty(" spring.datasource.url" )!! )
23+ .username(env.getProperty(" spring.datasource.username" )!! )
24+ .password(env.getProperty(" spring.datasource.password" )!! )
25+ .driverClassName(env.getProperty(" spring.datasource.driver-class-name" )!! )
26+ .build()
27+ }
Original file line number Diff line number Diff line change 1+ package com.wafflestudio.team2server.config
2+
3+ import io.swagger.v3.oas.models.Components
4+ import io.swagger.v3.oas.models.OpenAPI
5+ import io.swagger.v3.oas.models.info.Info
6+ import io.swagger.v3.oas.models.security.SecurityRequirement
7+ import io.swagger.v3.oas.models.security.SecurityScheme
8+ import org.springframework.context.annotation.Bean
9+ import org.springframework.context.annotation.Configuration
10+
11+ @Configuration
12+ class SwaggerConfig {
13+ @Bean
14+ fun customOpenAPI (): OpenAPI {
15+ val securitySchemeName = " bearerAuth"
16+
17+ return OpenAPI ()
18+ .info(
19+ Info ()
20+ .title(" Wafflestudio 2025 Spring Boot team2-server API" )
21+ .version(" 1.0" ),
22+ ).addSecurityItem(
23+ SecurityRequirement ().addList(securitySchemeName),
24+ ).components(
25+ Components ()
26+ .addSecuritySchemes(
27+ securitySchemeName,
28+ SecurityScheme ()
29+ .name(securitySchemeName)
30+ .type(SecurityScheme .Type .HTTP )
31+ .scheme(" bearer" )
32+ .bearerFormat(" JWT" )
33+ .description(" JWT 토큰을 입력하세요" ),
34+ ),
35+ )
36+ }
37+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ spring.application.name=23-5-team2-server
44spring.datasource.url =jdbc:mysql://localhost:3306/${DB_NAME:mydatabase}
55spring.datasource.username =${DB_USER:user}
66spring.datasource.password =${DB_PASSWORD:secret}
7+ spring.datasource.driver-class-name =com.mysql.cj.jdbc.Driver
78
89# Flyway Settings
910spring.flyway.enabled =true
Original file line number Diff line number Diff line change @@ -2,8 +2,14 @@ package com.wafflestudio.team2server
22
33import org.junit.jupiter.api.Test
44import org.springframework.boot.test.context.SpringBootTest
5+ import org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc
6+ import org.springframework.test.context.ActiveProfiles
7+ import org.testcontainers.junit.jupiter.Testcontainers
58
69@SpringBootTest
10+ @ActiveProfiles(" test" )
11+ @Testcontainers
12+ @AutoConfigureMockMvc
713class ApplicationTests {
814 @Test
915 fun contextLoads () {
Original file line number Diff line number Diff line change 1+ spring.config.activate.on-profile =test
2+ spring.datasource.url =jdbc:tc:mysql:8.0:///$DB_NAME
3+ spring.datasource.driver-class-name = org.testcontainers.jdbc.ContainerDatabaseDriver
4+ spring.flyway.enabled =true
You can’t perform that action at this time.
0 commit comments