The bean injected into the ignite service is empty

Source: Internet
Author: User

When writing the Ignite service, the service is typically configured in the startup file:

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>                class = "Com.***impl" ></bean>

Classes injected in the implementation class

    @Autowired    private ctsmgr ctsmgr;    

According to Spring's habit we inject interfaces usually choose @autowired or @resource,ignite is also compatible with spring. But when the deployment of the service occurs after the startup, that is, when the service is not configured in the configuration file:

        New serviceconfiguration ();        Cfg.settotalcount (4);        Cfg.setmaxpernodecount (2);        Cfg.setname ("***impl");        Cfg.setservice (new  ***impl ());        Ignition.ignite (). Services (). deploy (CFG);

At this point, the service will find that the ctsmgr is null, it is necessary to use the Ignite annotation, the interface injection is replaced by:

    @SpringResource (resourcename = "Ctsmgr")    privatetransient ctsmgr ctsmgr;

You can see that the code is working again.

The bean injected into the ignite service is empty

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.