正如标题所说,ignite的注入特性在我的服务上不起作用。
我的服务接口代码很简单
trait FeederService extends Service with Logging{
@IgniteInstanceResource protected var ignite: Ignite = _
// log.info(s"ignite instance: ${ignite.toString}")
def runNewFeeders(qty: Int)
}下面是我的服务实现
override def init(ctx: ServiceContext): Unit = {
log.info(s"Initializing service ${ctx.name()}")
log.info(s"ignite instance: ${ignite.toString}")
}此代码崩溃,因为ignite对象为空。
我的服务部署大体上如下(当然,我可以在main方法中访问Ignite对象)
ignite.services(clientGroup).deployNodeSingleton("feeder-swarm",
new FeederServiceImpl())不知道是否相关,但clientGroup是用
val clientGroup = ignite.cluster().forAttribute("client", "true")因为我的节点没有使用Ignite客户机定义(从Ignite的角度来看,它们都是服务器)
有什么帮助吗?谢谢
发布于 2018-05-21 19:24:28
问题是您试图在注入之前访问Ignite实例。
Ignite只能在对象构造之后被注入,但是您的实例初始化器试图使用它(${ignite.toString}),但失败了。
将您的log.info调用移动到init方法,它将会工作。
https://stackoverflow.com/questions/50446814
复制相似问题