我正在开发一个使用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}}特征中声明