我正在尝试 Ignite 2.16。但是,配置 ignite-indexing 后,启动显示异常为“java.lang.NoClassDefFoundError:org/h2/value/ValueByte .....”。
在我看来像是 h2 版本兼容性问题。 ignite-indexing 自动拉入的默认 h2 版本是 h2-2.2.224.jar。我认为 Ignite 需要一个较低版本的 h2 库,其中包含 org.h2.value.ValueByte 类。
有人可以建议我需要强制进入 gradle 的正确/兼容的 h2 库版本吗?
版本1.4.197。 Ignite 的模块之一不太可能引入了错误的版本。很有可能,这就像春天一样。
您需要设置正确的依赖项:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.197</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-core</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-indexing</artifactId>
<version>2.16.0</version>
</dependency>
<dependency>
<groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring</artifactId>
<version>2.16.0</version>
</dependency>
并创建一个配置类:
@Configuration
public class IgniteConfig {
@Bean
public Ignite igniteInstance() {
IgniteConfiguration config = new IgniteConfiguration();
TcpDiscoverySpi spi = new TcpDiscoverySpi();
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
spi.setIpFinder(ipFinder);
config.setDiscoverySpi(spi);
return Ignition.start(config);
}
@Bean
public IgniteCache<String, Map<String, Object>> igniteCache(Ignite ignite) {
CacheConfiguration<String, Map<String, Object>> cacheCfg = new CacheConfiguration<>("imageDataCache");
cacheCfg.setIndexedTypes(String.class, HashMap.class);
return ignite.getOrCreateCache(cacheCfg);
}
}