https://kotlinlang.org logo
#ktor
Title
# ktor
m

Muhammad Talha

04/25/2022, 7:46 AM
Hi all! I’m new to Kotlin and Ktor. I just generated a Ktor project from https://start.ktor.io/. I added the routing, content negotiation, and kotlinx.serialization plugins. When I try to build my project I’m getting a
Unresolved reference: ContentNegotiation
error in
com/talhaguy/plugins/Serialization.kt
. Does any one know how I can get past this error? Thanks in advance! I have a feeling not everything I needed got generated. I was following the https://ktor.io/docs/creating-http-apis.html#source_code tutorial and the
/src/main/resources/application.conf
did not get generated either and I manually created it.
🤦‍♂️ just had to add
import io.ktor.server.plugins.contentnegotiation.*
- problem solved!
s

sindrenm

04/25/2022, 8:46 AM
Kotlin requires you to import everything you use in your file (with a few exceptions, e.g. standard library stuff). Some (most?) IDEs that support Kotlin would help you with this by providing “fixes” to import those classes for you. simple smile
👍 1