通过编程方式从防暴螺栓中删除拓扑时发生编译错误:具有相同名称的对象和程序包 [英] Compile Error when killing topology from storm bolt programatically: object and package with same name
问题描述
我一直在寻找如何从我的Scala项目中的风暴1.2.1
中的风暴螺栓中杀死拓扑的方法.
在此 answer 中,我编写了以下代码来做到这一点:
I was looking for how to kill a topology from a storm bolt in storm 1.2.1
in my scala project.
From this answer, I wrote following code to do it:
private def shutTopology(){
import org.apache.storm.utils.Utils
import org.apache.storm.utils.NimbusClient
val conf = Utils.readStormConfig
val nimbusClient =
NimbusClient.getConfiguredClient(conf).getClient
nimbusClient.deactivate(topology_name)
}
但是它在行中给出了以下错误:val conf = Utils.readStormConfig
,该如何解决?
But it given following error in line: val conf = Utils.readStormConfig
, How to resolve this?
错误:(46,17)软件包守护程序包含对象和具有相同名称的软件包:nimbus
Error:(46, 17) package daemon contains object and package with same name: nimbus
其中之一需要从类路径中删除
one of them needs to be removed from classpath
val conf = Utils.readStormConfig
val conf = Utils.readStormConfig
通过同时通过sbt
和mvn
进行编译,我克服了错误.我在此处看到了一些说明,但在如何操作方面没有太多帮助解决这个问题.
I get above error by compiling via both sbt
and mvn
. I see some description for this here but not much help on how to resolve this.
基于答案此处,我能够使用以下scalac
选项在sbt
中对其进行编译:
Based on the answer here, I was able to compile this in sbt
using following scalac
options:
"-Yresolve-term-conflict:object"
使用Maven进行编译时,我仍然无法解决该错误.
I am stil not able to get this done how to resolve this error when compiling with maven.
推荐答案
基于答案此处,我能够使用以下scalac选项在sbt中对此进行编译:
Based on the answer here, I was able to compile this in sbt using following scalac options:
"-Yresolve-term-conflict:object"
要使用Maven进行编译,我按照建议的此处在pom.xml中进行了以下更改:
to get this compiled with maven, I did following changes in my pom.xml as suggested here:
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-Yresolve-term-conflict:object</arg> //this was added
</args>
<jvmArgs>
<jvmArg>-Xms2048m</jvmArg>
<jvmArg>-Xmx4096m</jvmArg>
</jvmArgs>
</configuration>
这篇关于通过编程方式从防暴螺栓中删除拓扑时发生编译错误:具有相同名称的对象和程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!