在写ignite服务的时候,通常服务配置在启动文件中:

<bean class="org.apache.ignite.services.ServiceConfiguration">
<property name="name" value="***Impl" />
<property name="maxPerNodeCount" value="1" />
<property name="totalCount" value="1" />
<property name="service">
<ref bean="CronServiceImpl" />
</property>
</bean>
<bean id="CronServiceImpl" class="com.***Impl"></bean>

实现类中注入的类

    @Autowired
private CtsMgr ctsMgr;

按照spring习惯我们注入接口通常选择@Autowired或者@Resource,ignite也是兼容spring的.但是当服务的部署发生在启动之后,也就是服务没有配置在配置文件中时:

        ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setTotalCount(4);
cfg.setMaxPerNodeCount(2);
cfg.setName("***Impl");
cfg.setService(new ***Impl());
Ignition.ignite().services().deploy(cfg);

这时候再调用服务会发现,ctsMgr为null,这里需要用到ignite的注解,将接口注入替换为:

    @SpringResource(resourceName = "ctsMgr")
private transient CtsMgr ctsMgr;

可以发现代码又可以正常运行了哟

ignite服务中的bean注入为空的更多相关文章

  1. Spring中给Bean注入集合

    Spring中如果一个Bean里含有集合元素,需要给Bean里的集合元素注入元素时,可以采用如下方法,一个是构造器注入,一个是setter注入 JavaBean源代码: import java.uti ...

  2. 【Spring注解驱动开发】在@Import注解中使用ImportBeanDefinitionRegistrar向容器中注册bean

    写在前面 在前面的文章中,我们学习了如何使用@Import注解向Spring容器中导入bean,可以使用@Import注解快速向容器中导入bean,小伙伴们可以参见<[Spring注解驱动开发] ...

  3. xfire发布的Webservice中Spring注入为空的解决方案

    Spring框架使用中注入为空是一个比较头疼的问题,遇到Webservice和Spring框架配合时,这个问题更容易出现并很难发现问题的原因. 在做SSO系统中就遇到这样的问题,在Service的实现 ...

  4. ASP.NET Core中的依赖注入(3): 服务的注册与提供

    在采用了依赖注入的应用中,我们总是直接利用DI容器直接获取所需的服务实例,换句话说,DI容器起到了一个服务提供者的角色,它能够根据我们提供的服务描述信息提供一个可用的服务对象.ASP.NET Core ...

  5. spring中bean配置和bean注入

    1 bean与spring容器的关系 Bean配置信息定义了Bean的实现及依赖关系,Spring容器根据各种形式的Bean配置信息在容器内部建立Bean定义注册表,然后根据注册表加载.实例化Bean ...

  6. 解决SpringBoot中webScocket不能注入bean的问题

    最近在做websocket聊天,但是遇到一个问题,就是在websocket的服务中要调用Service层的东西.首先我想到的是通过@Autowire注解来实现bean的注入.但是进过测试发现,注入的b ...

  7. spring扩展点之二:spring中关于bean初始化、销毁等使用汇总,ApplicationContextAware将ApplicationContext注入

    <spring扩展点之二:spring中关于bean初始化.销毁等使用汇总,ApplicationContextAware将ApplicationContext注入> <spring ...

  8. 解决 spring boot 线程中使用@Autowired注入Bean的方法,报java.lang.NullPointerException异常

    问题描述 在开发中,因某些业务逻辑执行时间太长,我们常使用线程来实现.常规服务实现类中,使用 @Autowired 来注入Bean,来调用其中的方法.但如果在线程类中使用@Autowired注入的Be ...

  9. ASP.NET Core中的依赖注入(4): 构造函数的选择与服务生命周期管理

    ServiceProvider最终提供的服务实例都是根据对应的ServiceDescriptor创建的,对于一个具体的ServiceDescriptor对象来说,如果它的ImplementationI ...

随机推荐

  1. Spring Security(11)——匿名认证

    目录 1.1     配置 1.2     AuthenticationTrustResolver 对于匿名访问的用户,Spring Security支持为其建立一个匿名的AnonymousAuthe ...

  2. 同一级目录js的引入

  3. 一行一行分析JQ源码学习笔记-03

    rquickExpr: <p>aaaa   或  #div1 rsingieTag: rmsPrefix :/-ms-/  是否是ie rdashAlpha = 转大小写   数字 (-2 ...

  4. 6、Struts2拦截器实现权限控制

    1.创建如下项目结果 2.在com.entity包下创建 package com.entity; public class User { private String name; private St ...

  5. Spring contextConfigLocation默认加载文件的位置

    在使用Spring框架的时候,如果我们使用的是XML文件配置Bean的方式的话,我们往往会在web.xml里面配置如下内容: <context-param> <param-name& ...

  6. Cross Product

    Cross Product These are two vectors: They can be multiplied using the "Cross Product" (als ...

  7. 2016NEFU集训第n+5场 A - Chinese Girls' Amusement

    Description       You must have heard that the Chinese culture is quite different from that of Europ ...

  8. Gentoo:Xorg:Failed to load module "……" 问题

    错误描述: 安装完xorg-server后,startx启动桌面环境,出现缺少模块错误. Xorg:Failed to load module "--" 查看log: cat /v ...

  9. chapter9_2 管道与过滤器

    一个关于协同程序的经典示例就是“生产者-消费者”的问题. 一个不断产生值,一个不断消费这些值.比如: function producer() while true do local x = io.re ...

  10. sql注入绕过union select过滤

    # # # #WAF Bypassing Strings: /*!%55NiOn*/ /*!%53eLEct*/ ,,)-- - +union+distinct+select+ +union+dist ...