File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
examples/spring-boot-kotlin-redis
src/main/kotlin/com/example/redis Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 1+ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
13plugins {
24 id(" org.springframework.boot" ) version " 2.7.10"
3- id( " org.jetbrains.kotlin. jvm" ) version " 1.8.10"
4- id( " org.jetbrains.kotlin. plugin.spring" ) version " 1.8.20"
5+ kotlin( " jvm" ) version " 1.8.10"
6+ kotlin( " plugin.spring" ) version " 1.8.20"
57}
68
7- apply plugin : ' io.spring.dependency-management '
9+ java.sourceCompatibility = JavaVersion . VERSION_1_8
810
911repositories {
1012 mavenCentral()
1113}
1214
1315dependencies {
16+ apply (plugin = " io.spring.dependency-management" )
1417 implementation(" org.springframework.boot:spring-boot-starter" )
1518 implementation(" org.jetbrains.kotlin:kotlin-stdlib-jdk8" )
1619 implementation(" org.springframework.boot:spring-boot-starter-data-redis" )
1720 implementation(" org.springframework.boot:spring-boot-starter-web" )
1821
1922 testImplementation(" org.springframework.boot:spring-boot-starter-test" )
2023 testImplementation(" org.testcontainers:testcontainers" )
24+
25+
2126}
2227
23- compileKotlin {
28+ tasks.withType< KotlinCompile > {
2429 kotlinOptions {
30+ freeCompilerArgs = listOf (" -Xjsr305=strict" )
2531 jvmTarget = " 1.8"
26- freeCompilerArgs = [" -Xjsr305=strict" ]
2732 }
2833}
Original file line number Diff line number Diff line change 11package com.example.redis
22
3- import org.springframework.beans.factory.annotation.Autowired
43import org.springframework.data.redis.core.RedisTemplate
54import org.springframework.web.bind.annotation.GetMapping
65import org.springframework.web.bind.annotation.PostMapping
76import org.springframework.web.bind.annotation.RequestBody
87import org.springframework.web.bind.annotation.RestController
98
109@RestController
11- class ExampleController {
10+ class ExampleController (
11+ private val redisTemplate : RedisTemplate <String , String >
12+ ) {
1213
13- private val key = " testcontainers"
14-
15- @Autowired
16- private lateinit var redisTemplate: RedisTemplate <String , String >
14+ companion object {
15+ const val key = " testcontainers"
16+ }
1717
1818 @PostMapping(" /set-foo" )
1919 fun setFoo (@RequestBody value : String ) {
You can’t perform that action at this time.
0 commit comments