如何在 Spring Boot 中使用 Ignite?我用谷歌搜索但没有成功。有没有人体验过 Spring Boot 和 Ignite 的结合?
这是使用 Spring Boot 运行 Ignite 的正确方法吗? Apache Ignite 使用 Spring-Boot 加载两次?
如何在 Spring Boot 中使用 Ignite?我用谷歌搜索但没有成功。有没有人体验过 Spring Boot 和 Ignite 的结合?
这是使用 Spring Boot 运行 Ignite 的正确方法吗? Apache Ignite 使用 Spring-Boot 加载两次?
我有测试项目 spring boot + ignite。我希望这会有所帮助: github项目
目前已经与 Spring Boot 直接集成,因此您应该在应用程序中手动启动节点 usingIgnition.start()
方法。
对于我的用例,我创建了一个 bean 并在返回 ignite 之后开始在其中点燃。它只会在开始时点燃一次。
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");
}
}