简体   繁体   中英

Bean Autowiring problem

I am starter in mutithreading. I am trying to index my data into solr.For that I was writing the following code

I am getting null pointer exception in the line highlighted

You need to add the following:

<context:annotation-config/>

You need to set the path for autowiring package scan and in your case it will be:

<context:component-scan base-package="a.b.c" />

After it you need to mark the class as candidate for autowiring:

@Component("indexTask")
@Scope("prototype")
IndexTask implements Callable<IndexObject>
    {
    //ommited
     }

Next you can remove indexTask bean configuration from xml file. your package will be created automatically.

Hope it helps.

Autowiring doesn't happen automatically, you need to configure it. See the Spring docs for detail, but essentially you need to add

<context:annotation-config/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM