向build.sbt添加依赖项后,Scala运行失败

时间:2016-09-28 13:01:34

标签: scala sbt diameter-protocol

我有一个scala项目,可以编译并且可以无错误地执行。 我在我的模块的build.sbt文件中添加了直径依赖:

libraryDependencies ++= Seq(
    // some other dependencies here
    // then diameter dependencies
    "org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106",
    "org.mobicents.diameter" % "jdiameter-impl" % "1.7.0.106"
)

项目仍在编译但无法运行:

[app] $ compile
[success] Total time: 1 s, completed Sep 28, 2016 2:54:36 PM
[app] $ run

SLF4J: Class path contains multiple SLF4J bindings.

--- (Running the application, auto-reloading is enabled) ---

log4j:WARN No appenders could be found for logger (akka.event.slf4j.Slf4jLogger).
log4j:WARN Please initialize the log4j system properly.
java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
    at org.slf4j.bridge.SLF4JBridgeHandler.callLocationAwareLogger(SLF4JBridgeHandler.java:221)
    at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:297)
    at java.util.logging.Logger.log(Logger.java:738)
    at java.util.logging.Logger.doLog(Logger.java:765)
    at java.util.logging.Logger.logp(Logger.java:930)
    at org.jboss.netty.logging.JdkLogger.debug(JdkLogger.java:36)
    at org.jboss.netty.channel.socket.nio.SelectorUtil.<clinit>(SelectorUtil.java:57)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.getMaxThreads(NioServerSocketChannelFactory.java:248)
    at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.<init>(NioServerSocketChannelFactory.java:115)
    at play.core.server.NettyServer.play$core$server$NettyServer$$newBootstrap(NettyServer.scala:46)
    at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:130)
    at play.core.server.NettyServer$$anonfun$1.apply(NettyServer.scala:129)
    at scala.Option.map(Option.scala:146)
    at play.core.server.NettyServer.<init>(NettyServer.scala:129)
    at play.core.server.NettyServerProvider.createServer(NettyServer.scala:200)
    at play.core.server.NettyServerProvider.createServer(NettyServer.scala:199)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:208)
    at play.core.server.DevServerStart$$anonfun$mainDev$1.apply(DevServerStart.scala:61)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$.mainDev(DevServerStart.scala:60)
    at play.core.server.DevServerStart$.mainDevHttpMode(DevServerStart.scala:50)
    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:497)
    at play.runsupport.Reloader$.startDevMode(Reloader.scala:223)
    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 app/compile:run for the full output.
[error] (app/compile:run) java.lang.reflect.InvocationTargetException
[error] Total time: 2 s, completed Sep 28, 2016 2:54:42 PM

我不明白添加这两个依赖项会如何破坏应用程序。我可以在.ivy2缓存中看到下载的jar,以便解决新的依赖关系。

我该如何解决这个问题? 完整输出说:

java.lang.reflect.InvocationTargetException

非常感谢你的帮助

更新

如果我只添加此依赖项

"org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106"

它有效:)

但我需要两个:(

1 个答案:

答案 0 :(得分:1)

看起来两个依赖项都添加了自己的logger实现,并且它们在运行时发生冲突。

尝试从两个中的一个中排除它,例如:

libraryDependencies ++= Seq(
    "org.mobicents.diameter" % "jdiameter-api" % "1.7.0.106",
    "org.mobicents.diameter" % "jdiameter-impl" % "1.7.0.106" exclude("org.slf4j", "slf4j-jdk14")
)