How to use Aerospike in Spring framework like MongoDB

Hi, I am trying to use Aerospike in Spring framework just like MongoDB. I have gone through the official website and get these guides:

I found that you guys have used these pom dependencies:



I have found these dependencies in but could not find them valid. I need to implement spring based dependency in Gradle. Please guide me with valid dependency in Gradle, so that I can access aerospike in Spring framework.

I can access mongodb like : import but could not able to get : import (as mentioned in your docs and Git).

NOTE: I have used the above dependencies in my gradle project also and my gradle could not compile. It seems these are not valid maven repositories.

Hi Hafsa,

Spring Data for Aerospike is a Spring Community project controlled by Pivotal (Spring) and sponsored by Aerospike.

Currently there is an issue with the automated build of Spring Data for Aerospike preventing the JAR to be published in Maven Central, and Aerospike has raised these with Pivotal.

In the mean time, I recommend that you clone the GitHub repo and build it.

This build command will build, test and install it in your local Maven repo.

mvn clean install

I hope this helps


Thank you for your reply. It works for me, but I am getting one more issue related to Aerospike Template. Note: I am using gradle in spring framework.

I have this bean in my configuration:

    public @Bean  AerospikeClient aerospikeClient() {
        return new AerospikeClient(this.aerospikeHost(), this.aerospikePort());

    public @Bean AerospikeTemplate aerospikeTemplate() throws Exception {
        return new AerospikeTemplate(aerospikeClient(), "myNamespaceName");

If I Autowire aerospikeClient, It goes well in good. I m doing Autowiring like this:

        protected AerospikeClient aerospikeClient;

I have Autowired aerospike template like this:

    public AerospikeTemplate aerospikeTemplate;

And it is giving me this Exceptions:

5372 ERROR [main] --- SpringApplication: Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'prePushAnalysisService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aerospikeTemplate' defined in class path resource [com/matchinguu/analytics/ConfigurationHandler.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate []: Factory method 'aerospikeTemplate' threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(
    at org.springframework.boot.SpringApplication.refresh(
    at org.springframework.boot.SpringApplication.createAndRefreshContext(

Please guide me, what I am doing wrong. I use the same format for MongoDB and it is running fine.

specific exception is:

    at java.util.TreeMap.put(
    at com.aerospike.helper.query.QueryEngine.refreshIndexes(
    at com.aerospike.helper.query.QueryEngine.refreshCluster(
    at com.aerospike.helper.query.QueryEngine.<init>(

And I am following your repo example:

Hello Hafsa,

Have you resolved this problem with Autowired Annotation on Bean Objects? Because I have encountered the same problem!

I am also still facing this issue as Oct 24th 2016

I downloaded the spring-data-aerospike code and built it and using it.

added in gradle build file compile('')

along with

repositories {

But , Now i am getting an error

“required a bean named ‘aerospikeTemplate’ that could not be found” Action: Consider defining a bean named ‘aerospikeTemplate’ in your configuration.

I am having AeroSpikeConfiguration as below in package com.vkt.repository.configuration


public class AerospikeConfiguration {
    public @Bean(destroyMethod = "close") AerospikeClient aerospikeClient() {
        ClientPolicy policy = new ClientPolicy();
        policy.failIfNotConnected = true;
        return new AerospikeClient(policy, "localhost", 3000);

    public @Bean AerospikeTemplate aerospikeTemplate() {
        return new AerospikeTemplate(aerospikeClient(), "test");

I have the below code in my Service Layer @EnableAerospikeRepositories(basePackages = "com.vkt.repository")

Any clue what could be wrong

Hello folks, I am facing the same issue also as on Dec 9, 2016. I downloaded the spring-data-aerospike code and built it and using it in pom.xml.


I have also tried all methods but could not resolve the issue

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aerospikeTemplate'

Hello!I encouter the same problem as you。have you solved the problem yet?