Skip to content

Commit b6fef06

Browse files
committed
Upgraded to Spring 6.1.0-M5 and Spring Boot 3.2.0-M3. Tested that Kotlin value classes can be used to disambiguate Spring beans.
1 parent 3954765 commit b6fef06

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

build-logic/settings.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ dependencyResolutionManagement {
66
@Suppress("UnstableApiUsage")
77
repositories {
88
gradlePluginPortal()
9+
maven { setUrl("https://repo.spring.io/milestone") }
910
}
1011
versionCatalogs {
1112
create("libs") {

gradle/libs.versions.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ kotlinx-datetime = "0.4.1"
1414
log4j = "2.20.0"
1515
log4j-kotlin = "1.2.0"
1616
mockk = "1.13.8"
17-
spring = "6.0.12"
18-
spring-boot = "3.1.4"
17+
spring = "6.1.0-M5"
18+
spring-boot = "3.2.0-M3"
1919
spring-mockk = "4.0.2"
2020
versions-gradle-plugin = "0.48.0"
2121

settings.gradle.kts

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
pluginManagement {
22
includeBuild("build-logic")
3+
repositories {
4+
gradlePluginPortal()
5+
maven { setUrl("https://repo.spring.io/milestone") }
6+
}
37
}
48

59
plugins {
@@ -10,6 +14,7 @@ dependencyResolutionManagement {
1014
@Suppress("UnstableApiUsage")
1115
repositories {
1216
mavenCentral()
17+
maven { setUrl("https://repo.spring.io/milestone") }
1318
maven { setUrl("https://jitpack.io") }
1419
}
1520
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package org.sdkotlin.springdemo
2+
3+
import org.assertj.core.api.Assertions.assertThat
4+
import org.junit.jupiter.api.Test
5+
import org.springframework.beans.factory.annotation.Autowired
6+
import org.springframework.boot.test.context.SpringBootTest
7+
import org.springframework.context.annotation.Bean
8+
import org.springframework.context.annotation.Configuration
9+
import java.util.function.Supplier
10+
11+
@SpringBootTest
12+
internal class SpringKotlinValueClassIT {
13+
14+
@Configuration
15+
internal class TestConfig {
16+
17+
@Bean
18+
fun helloFunction(): () -> HelloString =
19+
{ HelloString("Hello") }
20+
21+
@Bean
22+
fun worldFunction(): () -> WorldString =
23+
{ WorldString("World") }
24+
25+
@Bean
26+
fun helloSupplier(): Supplier<HelloString> =
27+
Supplier { HelloString("Hello") }
28+
29+
@Bean
30+
fun worldSupplier(): Supplier<WorldString> =
31+
Supplier { WorldString("World") }
32+
}
33+
34+
@Test
35+
fun `test Kotlin value class function beans with Spring`(
36+
@Autowired
37+
helloFunction: () -> HelloString,
38+
@Autowired
39+
worldFunction: () -> WorldString,
40+
) {
41+
42+
val helloWorld =
43+
"${helloFunction().value}, ${worldFunction().value}!"
44+
45+
assertThat(helloWorld).isEqualTo("Hello, World!")
46+
}
47+
48+
@Test
49+
fun `test Kotlin value class Supplier beans with Spring`(
50+
@Autowired
51+
helloSupplier: Supplier<HelloString>,
52+
@Autowired
53+
worldSupplier: Supplier<WorldString>,
54+
) {
55+
56+
val helloWorld =
57+
"${helloSupplier.get().value}, ${worldSupplier.get().value}!"
58+
59+
assertThat(helloWorld).isEqualTo("Hello, World!")
60+
}
61+
62+
@JvmInline
63+
value class HelloString(val value: String)
64+
65+
@JvmInline
66+
value class WorldString(val value: String)
67+
}

0 commit comments

Comments
 (0)