应用场景:开发插件集成小公司的业务系统,需要将数据存储到多个表格里,有自定义的数据表,拟通过R2dbcRepository接口进行数据存储,但发现启动时没有相应的Bean。
Spring r2dbc data 不理睬插件里的Repository定义?
部分运行日志如下:
p.core.extension.reconciler.PluginReconciler-worker-1 aborted with an error, re-enqueuing...
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'run.halo.tutorial.service.ReviewHandler#0': Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'run.halo.tutorial.repository.ReviewRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:237) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapab
leBeanFactory.java:1355) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1192) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:562) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:522) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:325) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:323) ~[spring-beans-6.1.4.jar:6.1.4]
at o
rg.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:975) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:959) ~[spring-context-6.1.4.jar:6.1.4]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:624) ~[spring-context-6.1.4.jar:6.1.4]
at run.halo.app.plugin.DefaultPluginApplicationContextFactory.create(DefaultPluginApplicationContextFactory.java:165) ~[classes/:2.13.0]
at run.halo.app.plugin.SpringPlugin.start(SpringPlugin.java:30) ~[classes/:2.13.0]
at org.pf4j.AbstractPluginManager.startPlugin(AbstractPluginManager.java:408) ~[pf4j-3.10.0.jar:3.10.0]
at run.halo.app.core.extension.reconciler.PluginReconciler.startPlugin(PluginRecon
ciler.java:200) ~[classes/:2.13.0]
at run.halo.app.core.extension.reconciler.PluginReconciler.lambda$reconcile$0(PluginReconciler.java:120) ~[classes/:2.13.0]
at java.base/java.util.Optional.map(Unknown Source) ~[na:na]
at run.halo.app.core.extension.reconciler.PluginReconciler.reconcile(PluginReconciler.java:96) ~[classes/:2.13.0]
at run.halo.app.core.extension.reconciler.PluginReconciler.reconcile(PluginReconciler.java:65) ~[classes/:2.13.0]
at run.halo.app.extension.controller.DefaultController$Worker.run(DefaultController.java:163) ~[api-2.13.0.jar:na]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(Unknown Source) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) ~[na:na]
at java.base/java.lang.Thread.run(Unknown Source) ~[na:na]
Caused by: org.springframework.beans.
factory.NoSuchBeanDefinitionException: No qualifying bean of type 'run.halo.tutorial.repository.ReviewRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1880) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1406) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1353) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:907) ~[spring-beans-6.1.4.jar:6.1.4]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:785) ~[spring-beans-6.1.4.jar:6.1.4]
... 26 common
frames omitted