Skip to content

Commit e764b79

Browse files
committed
[DEPENDENCY] Spring Boot 4.0
kotlinVersion=2.2.21 asciidoctorConvertVersion=4.0.5 ktlintVersion=14.0.1 springBootVersion=4.0.0 springCloudDependenciesVersion=2025.1.0 springMockkVersion=5.0.1 sentryVersion=8.27.1 gradle=9.2.1
1 parent 311fc87 commit e764b79

File tree

19 files changed

+102
-106
lines changed

19 files changed

+102
-106
lines changed

build.gradle.kts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2-
31
plugins {
42
kotlin("jvm")
5-
kotlin("kapt")
63
kotlin("plugin.spring") apply false
74
kotlin("plugin.jpa") apply false
85
id("org.springframework.boot") apply false
@@ -11,8 +8,6 @@ plugins {
118
id("org.jlleitschuh.gradle.ktlint") apply false
129
}
1310

14-
java.sourceCompatibility = JavaVersion.valueOf("VERSION_${property("javaVersion")}")
15-
1611
allprojects {
1712
group = "${property("projectGroup")}"
1813
version = "${property("applicationVersion")}"
@@ -24,7 +19,6 @@ allprojects {
2419

2520
subprojects {
2621
apply(plugin = "org.jetbrains.kotlin.jvm")
27-
apply(plugin = "org.jetbrains.kotlin.kapt")
2822
apply(plugin = "org.jetbrains.kotlin.plugin.spring")
2923
apply(plugin = "org.jetbrains.kotlin.plugin.jpa")
3024
apply(plugin = "org.springframework.boot")
@@ -40,28 +34,32 @@ subprojects {
4034

4135
dependencies {
4236
implementation("org.jetbrains.kotlin:kotlin-reflect")
43-
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
4437
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
45-
testImplementation("org.springframework.boot:spring-boot-starter-test")
46-
testImplementation("com.ninja-squad:springmockk:${property("springMockkVersion")}")
4738
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
48-
kapt("org.springframework.boot:spring-boot-configuration-processor")
39+
testImplementation("org.springframework.boot:spring-boot-test")
40+
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
41+
testImplementation("org.assertj:assertj-core")
42+
testImplementation("com.ninja-squad:springmockk:${property("springMockkVersion")}")
4943
}
5044

51-
tasks.getByName("bootJar") {
52-
enabled = false
45+
java {
46+
toolchain {
47+
languageVersion = JavaLanguageVersion.of("${property("javaVersion")}")
48+
}
5349
}
5450

55-
tasks.getByName("jar") {
56-
enabled = true
51+
kotlin {
52+
compilerOptions {
53+
freeCompilerArgs.addAll("-Xjsr305=strict", "-Xannotation-default-target=param-property")
54+
}
5755
}
5856

59-
java.sourceCompatibility = JavaVersion.valueOf("VERSION_${property("javaVersion")}")
60-
tasks.withType<KotlinCompile> {
61-
kotlinOptions {
62-
freeCompilerArgs = listOf("-Xjsr305=strict")
63-
jvmTarget = "${project.property("javaVersion")}"
64-
}
57+
tasks.named<Jar>("bootJar").configure {
58+
enabled = false
59+
}
60+
61+
tasks.named<Jar>("jar").configure {
62+
enabled = true
6563
}
6664

6765
tasks.test {
@@ -98,7 +96,7 @@ subprojects {
9896
}
9997
}
10098

101-
tasks.getByName("asciidoctor") {
99+
tasks.named("asciidoctor").configure {
102100
dependsOn("restDocsTest")
103101
}
104102
}

core/core-api/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
tasks.getByName("bootJar") {
1+
tasks.named<Jar>("bootJar").configure {
22
enabled = true
33
}
44

5-
tasks.getByName("jar") {
5+
tasks.named<Jar>("jar").configure {
66
enabled = false
77
}
88

@@ -15,5 +15,5 @@ dependencies {
1515

1616
testImplementation(project(":tests:api-docs"))
1717

18-
implementation("org.springframework.boot:spring-boot-starter-web")
18+
implementation("org.springframework.boot:spring-boot-starter-webmvc")
1919
}

core/core-api/src/main/kotlin/io/dodn/springboot/core/api/config/AsyncConfig.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import java.util.concurrent.Executor
1111
@Configuration
1212
@EnableAsync
1313
class AsyncConfig : AsyncConfigurer {
14-
1514
@Bean
1615
override fun getAsyncExecutor(): Executor {
1716
val executor = ThreadPoolTaskExecutor()

core/core-api/src/main/kotlin/io/dodn/springboot/core/api/controller/v1/ExampleController.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.dodn.springboot.core.api.controller.v1
22

33
import io.dodn.springboot.core.api.controller.v1.request.ExampleRequestDto
4+
import io.dodn.springboot.core.api.controller.v1.response.ExampleItemResponseDto
45
import io.dodn.springboot.core.api.controller.v1.response.ExampleResponseDto
56
import io.dodn.springboot.core.domain.ExampleData
67
import io.dodn.springboot.core.domain.ExampleService
@@ -11,6 +12,8 @@ import org.springframework.web.bind.annotation.PostMapping
1112
import org.springframework.web.bind.annotation.RequestBody
1213
import org.springframework.web.bind.annotation.RequestParam
1314
import org.springframework.web.bind.annotation.RestController
15+
import java.time.LocalDate
16+
import java.time.LocalDateTime
1417

1518
@RestController
1619
class ExampleController(
@@ -22,14 +25,14 @@ class ExampleController(
2225
@RequestParam exampleParam: String,
2326
): ApiResponse<ExampleResponseDto> {
2427
val result = exampleExampleService.processExample(ExampleData(exampleValue, exampleParam))
25-
return ApiResponse.success(ExampleResponseDto(result.data))
28+
return ApiResponse.success(ExampleResponseDto(result.data, LocalDate.now(), LocalDateTime.now(), ExampleItemResponseDto.build()))
2629
}
2730

2831
@PostMapping("/post")
2932
fun examplePost(
3033
@RequestBody request: ExampleRequestDto,
3134
): ApiResponse<ExampleResponseDto> {
3235
val result = exampleExampleService.processExample(request.toExampleData())
33-
return ApiResponse.success(ExampleResponseDto(result.data))
36+
return ApiResponse.success(ExampleResponseDto(result.data, LocalDate.now(), LocalDateTime.now(), ExampleItemResponseDto.build()))
3437
}
3538
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
package io.dodn.springboot.core.api.controller.v1.response
22

3+
import java.time.LocalDate
4+
import java.time.LocalDateTime
5+
36
data class ExampleResponseDto(
47
val result: String,
8+
val date: LocalDate,
9+
val datetime: LocalDateTime,
10+
val items: List<ExampleItemResponseDto>,
511
)
12+
13+
data class ExampleItemResponseDto(
14+
val key: String,
15+
) {
16+
companion object {
17+
fun build(): List<ExampleItemResponseDto> {
18+
return listOf(ExampleItemResponseDto("1"), ExampleItemResponseDto("2"))
19+
}
20+
}
21+
}

core/core-api/src/main/kotlin/io/dodn/springboot/core/support/error/ErrorMessage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package io.dodn.springboot.core.support.error
22

3-
data class ErrorMessage private constructor(
3+
class ErrorMessage private constructor(
44
val code: String,
55
val message: String,
66
val data: Any? = null,

core/core-api/src/main/kotlin/io/dodn/springboot/core/support/response/ApiResponse.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package io.dodn.springboot.core.support.response
33
import io.dodn.springboot.core.support.error.ErrorMessage
44
import io.dodn.springboot.core.support.error.ErrorType
55

6-
data class ApiResponse<T> private constructor(
6+
class ApiResponse<T> private constructor(
77
val result: ResultType,
88
val data: T? = null,
99
val error: ErrorMessage? = null,

core/core-api/src/test/kotlin/io/dodn/springboot/core/api/controller/v1/ExampleControllerTest.kt

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
package io.dodn.springboot.core.api.controller.v1
22

3+
import com.fasterxml.jackson.module.kotlin.jsonMapper
34
import io.dodn.springboot.core.api.controller.v1.request.ExampleRequestDto
45
import io.dodn.springboot.core.domain.ExampleResult
56
import io.dodn.springboot.core.domain.ExampleService
67
import io.dodn.springboot.test.api.RestDocsTest
7-
import io.dodn.springboot.test.api.RestDocsUtils.requestPreprocessor
8-
import io.dodn.springboot.test.api.RestDocsUtils.responsePreprocessor
98
import io.mockk.every
109
import io.mockk.mockk
11-
import io.restassured.http.ContentType
1210
import org.junit.jupiter.api.BeforeEach
1311
import org.junit.jupiter.api.Test
14-
import org.springframework.http.HttpStatus
12+
import org.springframework.http.MediaType
1513
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document
14+
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get
15+
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post
16+
import org.springframework.restdocs.operation.preprocess.Preprocessors
1617
import org.springframework.restdocs.payload.JsonFieldType
1718
import org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath
1819
import org.springframework.restdocs.payload.PayloadDocumentation.requestFields
1920
import org.springframework.restdocs.payload.PayloadDocumentation.responseFields
2021
import org.springframework.restdocs.request.RequestDocumentation
2122
import org.springframework.restdocs.request.RequestDocumentation.parameterWithName
2223
import org.springframework.restdocs.request.RequestDocumentation.queryParameters
24+
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
2325

2426
class ExampleControllerTest : RestDocsTest() {
2527
private lateinit var exampleService: ExampleService
@@ -34,19 +36,19 @@ class ExampleControllerTest : RestDocsTest() {
3436

3537
@Test
3638
fun exampleGet() {
37-
every { exampleService.processExample(any()) } returns ExampleResult("BYE")
39+
every { exampleService.processExample(any()) } returns ExampleResult("BYE_GET")
3840

39-
given()
40-
.contentType(ContentType.JSON)
41-
.queryParam("exampleParam", "HELLO_PARAM")
42-
.get("/get/{exampleValue}", "HELLO_PATH")
43-
.then()
44-
.status(HttpStatus.OK)
45-
.apply(
41+
mockMvc.perform(
42+
get("/get/{exampleValue}", "HELLO_PATH")
43+
.param("exampleParam", "HELLO_PARAM")
44+
.contentType(MediaType.APPLICATION_JSON),
45+
)
46+
.andExpect(status().isOk)
47+
.andDo(
4648
document(
4749
"exampleGet",
48-
requestPreprocessor(),
49-
responsePreprocessor(),
50+
Preprocessors.preprocessRequest(Preprocessors.prettyPrint()),
51+
Preprocessors.preprocessResponse(Preprocessors.prettyPrint()),
5052
RequestDocumentation.pathParameters(
5153
parameterWithName("exampleValue").description("ExampleValue"),
5254
),
@@ -55,7 +57,11 @@ class ExampleControllerTest : RestDocsTest() {
5557
),
5658
responseFields(
5759
fieldWithPath("result").type(JsonFieldType.STRING).description("ResultType"),
58-
fieldWithPath("data.result").type(JsonFieldType.STRING).description("Result Date"),
60+
fieldWithPath("data.result").type(JsonFieldType.STRING).description("Result Data"),
61+
fieldWithPath("data.date").type(JsonFieldType.STRING).description("Result Date"),
62+
fieldWithPath("data.datetime").type(JsonFieldType.STRING).description("Result Datetime"),
63+
fieldWithPath("data.items").type(JsonFieldType.ARRAY).description("Result Items"),
64+
fieldWithPath("data.items[].key").type(JsonFieldType.STRING).description("Result Item"),
5965
fieldWithPath("error").type(JsonFieldType.NULL).ignored(),
6066
),
6167
),
@@ -64,25 +70,29 @@ class ExampleControllerTest : RestDocsTest() {
6470

6571
@Test
6672
fun examplePost() {
67-
every { exampleService.processExample(any()) } returns ExampleResult("BYE")
73+
every { exampleService.processExample(any()) } returns ExampleResult("BYE_POST")
6874

69-
given()
70-
.contentType(ContentType.JSON)
71-
.body(ExampleRequestDto("HELLO_BODY"))
72-
.post("/post")
73-
.then()
74-
.status(HttpStatus.OK)
75-
.apply(
75+
mockMvc.perform(
76+
post("/post")
77+
.contentType(MediaType.APPLICATION_JSON)
78+
.content(jsonMapper().writeValueAsString(ExampleRequestDto("HELLO_BODY"))),
79+
)
80+
.andExpect(status().isOk)
81+
.andDo(
7682
document(
7783
"examplePost",
78-
requestPreprocessor(),
79-
responsePreprocessor(),
84+
Preprocessors.preprocessRequest(Preprocessors.prettyPrint()),
85+
Preprocessors.preprocessResponse(Preprocessors.prettyPrint()),
8086
requestFields(
8187
fieldWithPath("data").type(JsonFieldType.STRING).description("ExampleBody Data Field"),
8288
),
8389
responseFields(
8490
fieldWithPath("result").type(JsonFieldType.STRING).description("ResultType"),
85-
fieldWithPath("data.result").type(JsonFieldType.STRING).description("Result Date"),
91+
fieldWithPath("data.result").type(JsonFieldType.STRING).description("Result Data"),
92+
fieldWithPath("data.date").type(JsonFieldType.STRING).description("Result Date"),
93+
fieldWithPath("data.datetime").type(JsonFieldType.STRING).description("Result Datetime"),
94+
fieldWithPath("data.items").type(JsonFieldType.ARRAY).description("Result Items"),
95+
fieldWithPath("data.items[].key").type(JsonFieldType.STRING).description("Result Item"),
8696
fieldWithPath("error").type(JsonFieldType.STRING).ignored(),
8797
),
8898
),

gradle.properties

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ applicationVersion=0.0.1-SNAPSHOT
55
projectGroup=io.dodn.springboot
66

77
### Project dependency versions ###
8-
kotlinVersion=1.9.25
8+
kotlinVersion=2.2.21
99
javaVersion=21
1010

1111
### Plugin dependency versions ###
12-
asciidoctorConvertVersion=3.3.2
13-
ktlintVersion=13.0.0
12+
asciidoctorConvertVersion=4.0.5
13+
ktlintVersion=14.0.1
1414

1515
### Spring dependency versions ###
16-
springBootVersion=3.5.3
16+
springBootVersion=4.0.0
1717
springDependencyManagementVersion=1.1.7
18-
springCloudDependenciesVersion=2025.0.0
18+
springCloudDependenciesVersion=2025.1.0
1919

2020
### External dependency versions ###
21-
springMockkVersion=4.0.2
22-
sentryVersion=8.17.0
21+
springMockkVersion=5.0.1
22+
sentryVersion=8.27.1

gradle/wrapper/gradle-wrapper.jar

181 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)