'getting started with kotlin and SpringBootApplication to run some suspend fun
Trying to run this repo with some suspend functions. Can someone please give some hints?
Let say we have one
suspend fun log(){
mLog.subscribeAlways<GroupMessageEvent> { event ->
if (event.message.content.contains("Error")) {
print("****")
} else if (event.message.content.contains("Warning")) {
print("Warning")
}
}
mLog.Listen()
}
How can we trigger this log from main
open class Application {
companion object {
@JvmStatic fun main(args: Array<String>) {
SpringApplication.run(Application::class.java, *args)
}
}
}
What have try, it can run without error, but it didn't work as expected, call the log function from Controller class
class Controller {
@Value("\${spring.datasource.url}")
private var dbUrl: String? = null
@Autowired
lateinit private var dataSource: DataSource
@RequestMapping("/")
internal suspend fun index(): String {
mLog()
return "index"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
