...
plugins {
id("org.springframework.boot") version "2.1.5.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
kotlin("jvm") version "1.3.31"
kotlin("plugin.spring") version "1.3.31"
}
...
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.kotlin:spring-webflux-kotlin-coroutine:0.3.7")
implementation("org.springframework.kotlin:spring-data-mongodb-kotlin-coroutine:0.3.7")
implementation("org.springframework.kotlin:spring-boot-autoconfigure-kotlin-coroutine:0.3.7")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:1.3.0-M1")
}
...
Application configuration:
@Configuration
@EnableCoroutine
@EnableCoroutineMongoRepositories
class ApplicationConfiguration
Controller:
@Document(collection = "person")
data class Person(@Id val id: String? = null, val name: String)
interface PersonRepository : CoroutineMongoRepository<Person, String>
data class PersonForm(val name: String)
@RestController
@RequestMapping("/persons")
class PersonController(private val personRepository: PersonRepository) {
@GetMapping
suspend fun find(): List<Person> = personRepository.findAll()
@PostMapping
suspend fun create(@RequestBody form: PersonForm): Person = personRepository.save(Person(name = form.name))
}
When I send either GET or POST request, server responds with "COROUTINE_SUSPENDED":
Build:
Application configuration:
Controller:
When I send either GET or POST request, server responds with "COROUTINE_SUSPENDED":
It looks like a problem with webflux coroutine because data are stored to database.