Ignite and Spring Boot

Viewed 5846

How do I use Ignite with Spring Boot? I googled it but without success. Has anyone experience with the combination of Spring Boot and Ignite?

Is that the correct way to run Ignite in with Spring Boot? Apache Ignite Loading Twice with Spring-Boot?

4 Answers

Use following steps to integrate ignite with spring boot.

1. Add following dependency in POM.xml file
     
<dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-core</artifactId>
        <version>${ignite.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-spring</artifactId>
        <version>${ignite.version}</version>
    </dependency>
    <dependency>
   <groupId>org.apache.ignite</groupId>
   <artifactId>ignite-spring-data</artifactId>
   <version>${ignite.version}</version>
 </dependency>
    <dependency>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-indexing</artifactId>
        <version>${ignite.version}</version>
    </dependency> 
2. Create the Ignite bean instance
    @Bean
 public Ignite igniteInstance() {
     IgniteConfiguration cfg = new IgniteConfiguration();
        Ignite igniteInst= Ignition.start(cfg);
        return igniteInst;
    }
3. Configure the repository
@RepositoryConfig(cacheName = "cacheName")
public interface RepositoryName extends IgniteRepository<V, K> {
}

4. Autowired the RepositoryName interface which extends the IgniteRepository in service layer

@Component
public class ServiceImpl 
@Autowired
RepositoryName  repositoryName; 
}

5. You can use 5th steps apart from 4th steps to inject the ignite bean in service layer
@Component
public class ServiceImpl {
 @Autowired
 Ignite ignite;
    void abcMethod(){
     IgniteCache<K, V> igniteCache = ignite.cache("CacheName");
    }
}

Related