SymetricWebServer 不会在嵌入模式 (Spring Boot) 中创建 SYM* 表

问题描述

我有一个主服务器节点(称为 root),部署了独立安装存档,并在我的机器和 MysqL 数据库上使用“sym”命令行启动。 => 好的。

对于我的客户端服务器节点,我尝试在 H2 文件数据库中的 Spring Boot 中使用嵌入式 SymmetricDS。 (对于桌面应用程序) (我使用的是 SymmetricDS 3.12.5)

这是我的 Spring 启动代码

@Configuration
public class SymdsModule implements ApplicationListener<ApplicationReadyEvent> {

    @Autowired
    ServletContext servletContext;

    @Autowired
    DataSource dataSource;

    @Autowired
    ApplicationContext applicationContext;

    @Override
    final public void onApplicationEvent(ApplicationReadyEvent event) {
        SymmetricEngineHolder holder = new SymmetricEngineHolder();
        File propFile = null;
        try {
            propFile = new ClassPathResource(
                    "symmetric-client.properties").getFile();
            Properties propertiesFile = new Properties();
            propertiesFile.load(new FileReader(propFile));

            ServerSymmetricEngine serverEngine = new ServerSymmetricEngine(dataSource,applicationContext,propertiesFile,false,holder);
            serverEngine.setDeploymentType("server");
            System.out.println(serverEngine.getDeploymentType());
            holder.getEngines().put(propertiesFile.getProperty(ParameterConstants.EXTERNAL_ID),serverEngine);
            //holder.setAutoStart(false);
            servletContext.setAttribute(WebConstants.ATTR_ENGINE_HOLDER,holder);

            serverEngine.setup();
            serverEngine.openRegistration("store","002");
            serverEngine.start();
        } catch (IOException e) {
            e.printstacktrace();
        }
    }

    @Bean
    public ServletRegistrationBean<SymmetricServlet> symServlet() {
        ServletRegistrationBean<SymmetricServlet> bean = new ServletRegistrationBean<>(new SymmetricServlet(),"/sync");
        bean.setLoadOnStartup(1);
        return bean;
    }
}

对称客户端.properties:

engine.name=store-002
db.driver=org.h2.Driver
db.url=jdbc:h2:tcp://localhost:9090/~/mydb;AUTO_SERVER=TRUE;LOCK_TIMEOUT=60000
db.user=****
db.password=****
registration.url=http://localhost:31415/sync/root-000
group.id=store
external.id=002
job.routing.period.time.ms=5000
job.push.period.time.ms=10000
job.pull.period.time.ms=10000
auto.registration=true
initial.load.create.first=true
auto.config.database=true
start.refresh.cache.job=true
auto.sync.triggers=true
auto.reload = true;
https.verified.server.names=all

application.yml 文件

spring:
  application:
    name: myapp
  jpa:
    hibernate:
      ddl-auto: update
      properties:
        dialect: org.hibernate.dialect.H2Dialect
    show-sql: true
    properties:
      hibernate:
        search:
          default:
            directory_provider: filesystem
            indexBase: data/indexes/local/main
  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:/~/mydb;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE
    username: username
    password: password
  h2:
    console:
      enabled: true
server:
  port: 8183

在我的应用程序第一次启动时,SymmetricWebServer 没有像我预期的那样在 serverEngine.setup() 步骤中创建 SYM* 表。

--- [restartedMain] o.j.symmetric.AbstractSymmetricEngine : 初始化 SymmetricDS 数据库

--- [restartedMain] o.j.symmetric.db.h2.H2SymmetricDialect : 检查是否需要创建或更改 SymmetricDS 表

--- [restartedMain] o.j.s.service.impl.ConfigurationService : 自动配置配置通道

--- [restartedMain] 错误 org.springframework.boot.SpringApplication - 应用程序运行失败 org.jumpmind.db.sql.sqlException:找不到表“SYM_CHANNEL” 未找到表“SYM_CHANNEL”; sql语句

我尝试使用独立的对称安装命令在客户端 H2 数据库中创建对称表,然后重新启动我的 Spring Boot 应用程序。之后,一切正常,可以在 Spring boot 应用程序中与主节点同步...

嵌入式 SymetricWebServer 是否能够在第一次 Spring 启动执行时在我的客户端 H2 数据库自动创建 SYM* 表(如果它们不存在)?

我错过了什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)