[英]Akka not loading application.conf
I'm pretty new to Akka and I'm having trouble getting the application.conf
file to load. 我是Akka的新手,我无法加载application.conf
文件。 I've defined a relatively simple conf file, consisting of: 我已经定义了一个相对简单的conf文件,包括:
akka {
logLevel = "NONE"
stdout-logLevel = "NONE"
}
From what I understand, this should be picked up automatically (having put it in the src/main/resources
directory). 根据我的理解,这应该自动获取(将它放在src/main/resources
目录中)。 However, when I load the default logger and output "INFO" ( doing greet ) messages, I am still seeing them in the console (see following code). 但是,当我加载默认记录器并输出“INFO”( 做问候 )消息时,我仍然在控制台中看到它们(请参阅下面的代码)。
import akka.actor.{ActorRef, Actor, Props}
import akka.event.Logging
object HelloWorldActor {
case object Tick
}
class HelloWorldActor extends Actor {
val logger = Logging(context.system, this)
var greeter : Option[ActorRef] = None
override def preStart() = {
greeter = Some(context.actorOf(Props[Greeter], "greeter"))
}
def doGreet(): Unit = {
logger.info("doing greet")
greeter match {
case Some(g) => g ! Greeter.Greet
}
}
def receive: Actor.Receive = {
case HelloWorldActor.Tick => this.doGreet()
}
}
The only thing I can think of is that I have defined a kernel to run it in stand-alone mode and I'm not sure if there is something extra that I should be doing there to load the configuration. 我唯一能想到的是我已经定义了一个内核来在独立模式下运行它,我不确定是否还有一些额外的东西我应该在那里加载配置。
I've put my project up on GitHub for better inspection of what I am doing: https://github.com/JohnMurray/hello-akka 我已将我的项目放在GitHub上以更好地检查我正在做的事情: https : //github.com/JohnMurray/hello-akka
Any help is greatly appreciated since I'm currently an Akka newbie. 非常感谢任何帮助,因为我现在是Akka新手。 Also, I should mention that I have read through the config documentation online, but it didn't help me in this particular case. 另外,我应该提一下,我已经在线阅读了配置文档,但在这种特殊情况下它并没有帮助我。
thanks! 谢谢!
Try putting your file into src/main/resources/ - application.conf is not a scala file, so it doesn't belong in src/main/scala/resources which is the folder for the package root .resources scala sources. 尝试将文件放入src / main / resources / - application.conf不是scala文件,因此它不属于src / main / scala / resources,它是包root .resources scala源的文件夹。
OK. 好。 I see what is the problem now. 我现在看到了什么问题。 I don't think there's a loglevel setting NONE. 我不认为有一个loglevel设置NONE。
According to the doc there are four settings: 根据该文档 ,有四种设置:
# Options: ERROR, WARNING, INFO, DEBUG
loglevel = "DEBUG"
Try setting it to WARNING. 尝试将其设置为警告。
Also, you have typo in loglevel - please note it's not a camelCase name, but all-lower loglevel. 此外,你在loglevel中有拼写错误 - 请注意它不是camelCase名称,而是全部更低的loglevel。
Side note - add akka microkernel plugin to your SBT build and add runner that can be launched either with run or re-start action. 附注 - 将akka微内核插件添加到您的SBT构建中,并添加可以通过运行或重新启动操作启动的运行器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.