[alibaba/canal]canal-1.1.7-alpha-3 同步 es8 启动报错

2024-07-22 879 views
1

配置如下 image image Exception: Failed to bind properties under 'es-mapping' to com.alibaba.otter.canal.client.adapter.es.core.config.ESSyncConfig$ESMapping at com.alibaba.otter.canal.client.adapter.es8x.ES8xAdapter.init(ES8xAdapter.java:48) at com.alibaba.otter.canal.client.adapter.ProxyOuterAdapter.init(ProxyOuterAdapter.java:32) at com.alibaba.otter.canal.adapter.launcher.loader.CanalAdapterLoader.loadAdapter(CanalAdapterLoader.java:115) at com.alibaba.otter.canal.adapter.launcher.loader.CanalAdapterLoader.init(CanalAdapterLoader.java:71) at com.alibaba.otter.canal.adapter.launcher.loader.CanalAdapterService.init(CanalAdapterService.java:60) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:374) at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:376) at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:179) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:371) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) at org.springframework.cloud.context.scope.refresh.RefreshScope.eagerlyInitialize(RefreshScope.java:125) at org.springframework.cloud.context.scope.refresh.RefreshScope.start(RefreshScope.java:117) at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:112) at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:67) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) at com.alibaba.otter.canal.adapter.launcher.CanalAdapterApplication.main(CanalAdapterApplication.java:22) Caused by: java.lang.RuntimeException: java.lang.RuntimeException: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'es-mapping' to com.alibaba.otter.canal.client.adapter.es.core.config.ESSyncConfig$ESMapping at com.alibaba.otter.canal.client.adapter.es.core.ESAdapter.init(ESAdapter.java:72) at com.alibaba.otter.canal.client.adapter.es8x.ES8xAdapter.init(ES8xAdapter.java:46) ... 37 common frames omitted Caused by: java.lang.RuntimeException: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'es-mapping' to com.alibaba.otter.canal.client.adapter.es.core.config.ESSyncConfig$ESMapping at com.alibaba.otter.canal.client.adapter.support.YamlUtils.ymlToObj(YamlUtils.java:93) at com.alibaba.otter.canal.client.adapter.es.core.config.ESSyncConfigLoader.lambda$load$0(ESSyncConfigLoader.java:31) at java.base/java.util.HashMap.forEach(HashMap.java:1336) at com.alibaba.otter.canal.client.adapter.es.core.config.ESSyncConfigLoader.load(ESSyncConfigLoader.java:30) at com.alibaba.otter.canal.client.adapter.es.core.ESAdapter.init(ESAdapter.java:61) ... 38 common frames omitted Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'es-mapping' to com.alibaba.otter.canal.client.adapter.es.core.config.ESSyncConfig$ESMapping at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:384) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:344) at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:469) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:95) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:83) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:59) at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:473) at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:587) at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:573) at org.springframework.boot.context.properties.bind.Binder$Context.access$300(Binder.java:534) at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:471) at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:411) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:340) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:329) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:259) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:220) at com.alibaba.otter.canal.client.adapter.support.YamlUtils.ymlToObj(YamlUtils.java:91) ... 42 common frames omitted Caused by: org.springframework.boot.context.properties.source.InvalidConfigurationPropertyNameException: Configuration property name '-id' is not valid at org.springframework.boot.context.properties.source.ConfigurationPropertyName.elementsOf(ConfigurationPropertyName.java:612) at org.springframework.boot.context.properties.source.ConfigurationPropertyName.probablySingleElementOf(ConfigurationPropertyName.java:585) at org.springframework.boot.context.properties.source.ConfigurationPropertyName.append(ConfigurationPropertyName.java:208) at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$4(Binder.java:469) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:95) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:83) at org.springframework.boot.context.properties.bind.JavaBeanBinder.bind(JavaBeanBinder.java:59) at org.springframework.boot.context.properties.bind.Binder.lambda$bindDataObject$5(Binder.java:473) at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:587) at org.springframework.boot.context.properties.bind.Binder$Context.withDataObject(Binder.java:573) at org.springframework.boot.context.properties.bind.Binder$Context.access$300(Binder.java:534) at org.springframework.boot.context.properties.bind.Binder.bindDataObject(Binder.java:471) at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:411) at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:340) ... 57 common frames omitted 2023-09-14 18:03:29.260 [main] ERROR c.a.o.canal.adapter.launcher.loader.CanalAdapterService - ## something goes wrong when starting up the canal client adapters: java.lang.RuntimeException: instance=example,groupId=g1 Load OuterAdapters is Empty,pls check rdb.yml at com.alibaba.otter.canal.adapter.launcher.loader.CanalAdapterLoader.init(CanalAdapterLoader.java:79) at com.alibaba.otter.canal.adapter.launcher.loader.CanalAdapterService.init(CanalAdapterService.java:60) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:602) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:374) at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:376) at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:179) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:371) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) at org.springframework.cloud.context.scope.refresh.RefreshScope.eagerlyInitialize(RefreshScope.java:125) at org.springframework.cloud.context.scope.refresh.RefreshScope.start(RefreshScope.java:117) at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:112) at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:67) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) at org.springframework.boot.SpringApplication.run(SpringApplication.java:338) at com.alibaba.otter.canal.adapter.launcher.CanalAdapterApplication.main(CanalAdapterApplication.java:22) 2023-09-14 18:03:29.287 [main] INFO c.a.otter.canal.adapter.launcher.CanalAdapterApplication - Started CanalAdapterApplication in 10.817 seconds (JVM running for 13.198)

回答

6

遇到同样的问题,经过试验,是在加载 映射文件时出错, 应该是spring boot 版本升级后 读取以 '_' 开头的属性时出错, 尝试删除 yml 文件中所有 以 '_' 开头的属性,但还是报这个错误 ‘Configuration property name '-id' is not valid’ , 我猜这个 _id 不是在我的配置文件中的,应该是在模版文件中的

3

查了下代码, 问题原因不在配置文件上,而是在类定义上,类上有个方法叫 set_id(),用来映射配置文件中的 _id, 而是spring 5.3 以上不允许 以_开头的方法映射配置文件,set_id() 这个会被转成 -id , 而无论是_id 还是 -id 在 bind时都会被认为是非法的,我fork 并 把_去掉了,正在测试

1

可以提一个PR给我 @cooperlyt