导致java.lang.NoSuchMethodError异常的新依赖项

时间:2016-08-25 04:08:48

标签: scala spray nosuchmethoderror

我正在开发一个使用Scala ETCD客户端(https://github.com/nikore/scala-etcd)的项目,在添加Scala Fleet客户端(https://github.com/MonsantoCo/fleet-client)之前,这一切都很好。混合。

当我编译它很好但是一旦我运行项目它会在构造ETCDClient的行上抛出以下异常

Exception in thread "main" java.lang.NoSuchMethodError: spray.json.StandardFormats$class.optionFormat(Lspray/json/StandardFormats;Lspray/json/JsonFormat;)Lspray/json/StandardFormats$OptionFormat;
    at net.nikore.etcd.EtcdJsonProtocol$.optionFormat(EtcdJsonProtocol.scala:5)
    at net.nikore.etcd.EtcdJsonProtocol$.<init>(EtcdJsonProtocol.scala:18)
    at net.nikore.etcd.EtcdJsonProtocol$.<clinit>(EtcdJsonProtocol.scala)
    at net.nikore.etcd.EtcdClient.<init>(EtcdClient.scala:76)
    at net.nikore.etcd.EtcdClient$.apply(EtcdClient.scala:20)
    at au.com.someproject.helpers.SomeProjectService$class.main(SomeProjectService.scala:116)
    at au.com.someproject.some_agent.ServiceMain$.main(ServiceMain.scala:17)
    at au.com.someproject.some_agent.ServiceMain.main(ServiceMain.scala)

我打电话告诉可能导致这种情况的唯一原因是ETCD客户端需要spray-json 1.3.1但Fleet Client需要spray-json 1.3.2。查看已编译的包,spray-json 1.3.2已打包。

这是什么原因(如果我对依赖项有误),我该如何解决这个问题呢?

修改

Bellow是SomeProjectService.scala:116的代码:

etcdClient = EtcdClient(s"http://${serviceConfiguration.getString("someproject.etcd.host")}:${serviceConfiguration.getString("someproject.etcd.port")}")

以下是ServiceMain.scala:17的代码:

object ServiceMain extends SomeProjectService {

ServiceMain是服务的入口点,但main函数在声明SomeProjectService的{​​{1}}特征中声明

0 个答案:

没有答案