File tree 4 files changed +9
-27
lines changed
SpringBootAOP/src/main/kotlin/com/example/kotlin/web
SpringBootAsync/src/main/kotlin/com/example/kotlin
SpringBootCache/src/test/kotlin/com/example/kotlin
4 files changed +9
-27
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,7 @@ import org.springframework.web.bind.annotation.GetMapping
6
6
import org.springframework.web.bind.annotation.RestController
7
7
8
8
@RestController
9
- class TestController {
10
-
11
- @Autowired
12
- private lateinit var service: TestService
9
+ class TestController (val service : TestService ) {
13
10
14
11
@GetMapping(value = [" /noAop" ])
15
12
fun noAop (): String {
Original file line number Diff line number Diff line change @@ -7,29 +7,18 @@ import org.springframework.stereotype.Service
7
7
@Service
8
8
class BasicService {
9
9
10
+ companion object {
11
+ private val logger = LoggerFactory .getLogger(BasicService ::class .java)
12
+ }
13
+
10
14
@Async
11
15
fun onAsync () {
12
- try {
13
- Thread .sleep(1000 )
14
- } catch (e: InterruptedException ) {
15
- e.printStackTrace()
16
- }
17
-
16
+ Thread .sleep(1000 )
18
17
logger.info(" onAsync" )
19
18
}
20
19
21
20
fun onSync () {
22
- try {
23
- Thread .sleep(1000 )
24
- } catch (e: InterruptedException ) {
25
- e.printStackTrace()
26
- }
27
-
21
+ Thread .sleep(1000 )
28
22
logger.info(" onSync" )
29
23
}
30
-
31
- companion object {
32
-
33
- private val logger = LoggerFactory .getLogger(BasicService ::class .java)
34
- }
35
24
}
Original file line number Diff line number Diff line change @@ -12,10 +12,7 @@ import org.springframework.web.reactive.function.client.WebClient
12
12
import reactor.core.publisher.Mono
13
13
14
14
@RestController
15
- class BasicController {
16
-
17
- @Autowired
18
- private lateinit var service: BasicService
15
+ class BasicController (val service : BasicService ) {
19
16
20
17
private val logger = LoggerFactory .getLogger(BasicController ::class .java)
21
18
Original file line number Diff line number Diff line change @@ -17,9 +17,8 @@ class SpringBootCacheApplicationTests {
17
17
@Autowired
18
18
private lateinit var repository: BookRepository
19
19
20
- private var startTime: Long = 0
21
-
22
20
companion object {
21
+ private var startTime: Long = 0
23
22
private val logger = LoggerFactory .getLogger(SpringBootCacheApplicationTests ::class .java)
24
23
}
25
24
You can’t perform that action at this time.
0 commit comments