I'm trying to embed an akka-http server into my ammonite scala script.
Below is the scala code used to create a server instance
import ammonite.ops._
import $ivy.`com.typesafe:config:1.3.1`
import $ivy.`com.typesafe.akka:akka-http_2.12:10.0.6`
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import com.typesafe.config.ConfigFactory
import java.io._
@main
def main() = {
val fileConfig = ConfigFactory.parseFile(new File("resources/my.conf"))
val config = ConfigFactory.load(fileConfig)
println(config)
implicit val actorSystem = ActorSystem("system")
implicit val actorMaterializer = ActorMaterializer()
val route =
pathSingleSlash {
get {
complete {
"Hello world"
}
}
}
Http().bindAndHandle(route,"localhost",8080)
println("server started at 8080")
}
Here is the my.conf
file content:
akka {
loglevel = INFO
stdout-loglevel = INFO
default-dispatcher {
fork-join-executor {
parallelism-min = 8
}
}
Running the script with amm server.sc
I got the following error:
Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka'
The same happen with the standard application.conf
filename convention too.
I can read the file and get the content correctly. What I'm missing?
Thanks a lot