Spring 中嵌入模式的 SymmetricDS 作为客户端启动应用程序

SymmetricDS in Embedded mode in Spring boot app as client

我有一个使用 SymmetricDS 的 Spring 启动应用程序。当我想以嵌入式模式启动服务器和具有 h2 数据库的客户端时。

我创建了读取的配置文件,但客户端抛出以下错误:

org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'postgresBulkLoaderFactory' defined in class path resource [symmetric-ext-points.xml]:
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.jumpmind.symmetric.ext.PostgresBulkDataLoaderFactory]: 
Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: 
org/springframework/jdbc/support/nativejdbc/NativeJdbcExtractor

调试时肯定会读取配置。 DB是一个H2数据库,但是通过调试好像SymmetricDS找不到H2驱动,又回到默认使用Postgresql。

我的 gradle 看起来像这样:

 compile group: 'org.jumpmind.symmetric', name: 'symmetric-server', version: '3.5.19'
 compile group: 'org.jumpmind.symmetric', name: 'symmetric-client', version: '3.5.19'
 compile group: 'org.jumpmind.symmetric', name: 'symmetric-core', version: '3.5.19'

为什么不能使用我的H2数据库?检查 maven 存储库,核心应该有 h2 驱动程序,但仍然会抛出错误。

class org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor 不在 class 路径上。我建议尝试将 Spring 中包含此 class 的 jar 添加到依赖项列表,例如:https://www.findjar.com/class/org/springframework/jdbc/support/nativejdbc/NativeJdbcExtractor.html

你为什么要使用这么旧版本的 SymmetricDS?最新的是 3.11.8.

当我嵌入 SymmetricDS 时,我排除了可能会干扰 Spring Boot 提供的依赖项的依赖项。例如:

compile ("org.jumpmind.symmetric:symmetric-server:$symmetricVersion") {
     exclude group: 'org.slf4j'
     exclude group: 'com.mangofactory', module: 'swagger-springmvc'
     exclude group: 'org.springframework'
     exclude group: 'net.java.dev.jna'
}

这是 Spring 引导和 Spring 的以下版本:

springBootVersion=2.1.3.RELEASE
springVersion=5.1.5.RELEASE

如果您感兴趣,这里是我们如何将 SymmetricDS 嵌入 Spring Boot 的示例: