在Play Framework中导入Jar给了我java.lang.ClassCastException

时间:2016-10-13 22:59:55

标签: java intellij-idea playframework jar playframework-2.0

我在java中创建了一个库,我试图在我的Java Play Framework应用程序中使用Intellij。

文档告诉我,我只需要将它添加到项目中的lib文件夹中。

然而,当我在终端上输入激活器运行时,我有以下错误(在Intellij中可以看到该库,我可以在我的新代码中使用它):

java.lang.ClassCastException: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
at play.api.libs.logback.LogbackLoggerConfigurator.configure(LogbackLoggerConfigurator.scala:80)
at play.api.libs.logback.LogbackLoggerConfigurator.init(LogbackLoggerConfigurator.scala:26)
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:94)
at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:65)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:64)
at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:54)
at play.core.server.DevServerStart.mainDevHttpMode(DevServerStart.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at play.runsupport.Reloader$.startDevMode(Reloader.scala:234)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.devModeServer$lzycompute$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.play$sbt$run$PlayRun$$anonfun$$anonfun$$anonfun$$devModeServer$1(PlayRun.scala:74)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:100)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3.apply(PlayRun.scala:53)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 0 s, completed 13/out/2016 23:37:26

1 个答案:

答案 0 :(得分:0)

如果您的jar是非托管jar,这意味着它不是任何sbt repo的一部分,那么您需要在build.sbt中添加以下行。

unmanagedJars in Compile += file("lib/your_jar.jar")