Issue
In this code, as in this example, I try to configure resolver
via DirectoryCodeResolver
, but its parameter Path.of("somePath")
is incorrect, there is no such function.
Path
is from java.nio.file.Path
, but there is no of()
. Maybe, some file defines an extension for Path
class?
package com.example
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import com.example.plugins.*
import gg.jte.TemplateEngine
import gg.jte.resolve.DirectoryCodeResolver
import io.ktor.server.application.*
import io.ktor.server.jte.*
import java.nio.file.Path
fun main() {
embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
install(Jte) {
val resolver = DirectoryCodeResolver(Path.of("html"))
templateEngine = TemplateEngine.create(resolver, gg.jte.ContentType.Html)
}
configureRouting()
}.start(wait = true)
}
Solution
java.nio.file.Path
from Java 11 onwards has the static Path of(String first, String... more)
method (doc). It could be possible that you're using a lower Java version and hence not able to find that method in the standard lib.
Try upgrading your Java version and you should be able to use the method Path.of("html")
as shown in the example.
Answered By - Madhu Bhat
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.