在我的Spring-Boot项目中,我正试图实现MongoDb的数据库迁移,我对MongoDb和mongock很陌生。
下面是一些关于错误的细节,以及我到目前为止所做的工作:
-
我的pom有以下依赖项:
<artifactId>mongock-spring-v5</artifactId> <artifactId>mongodb-springdata-v3-driver</artifactId> <artifactId>mongock-bom</artifactId> <artifactId>testcontainers-bom</artifactId>
-
我已经用'
@EnableMongock
'注释了我的SpringBoot类 -
创建了一个DatabaseChangeLog类并注释了'@ChangeLog(order = "001")'在这个类中,我创建了'
@ChangeSet(order = "001", id = "00.00.00.01", author = "farzain pathan")
'并将一些数据插入数据库。 -
在"应用程序"中增加了下面一行。属性的文件
mongock.change-logs-scan-package = com.product.target.config
现在当我构建我的项目'mvn clean install'时,我得到以下错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongockBuilder' defined in class path resource [com/github/cloudyrock/spring/v5/MongockSpringDataV3CoreContext.class]: Bean instantiation via factory method failed; nested excep
tion is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.cloudyrock.spring.v5.MongockSpring5$Builder]: Factory method 'mongockBuilder' threw exception; nested exception is java.lang.NullPointerException: Cannot invoke "java.ut
il.List.iterator()" because "changeLogsScanPackage" is null
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[na:na]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:349) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$4(ClassBasedTestDescriptor.java:270) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.7.0.jar:1.7.0]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:269) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:259) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at java.base/java.util.Optional.orElseGet(Optional.java:362) ~[na:na]
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:258) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:101) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.7.0.jar:1.7.0]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:100) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:65) ~[junit-jupiter-engine-5.7.0.jar:5.7.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:111) ~[junit-platform-engine-1.7.0.jar:1.7.0]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.7.0.jar:1.7.0]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongockBuilder' defined in class path resource [com/github/cloudyrock/spring/v5/MongockSpringDataV3CoreContext.class]: Bean instantiation via factory method failed; n
ested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.cloudyrock.spring.v5.MongockSpring5$Builder]: Factory method 'mongockBuilder' threw exception; nested exception is java.lang.NullPointerException: Cannot invo
ke "java.util.List.iterator()" because "changeLogsScanPackage" is null
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1179) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:923) ~[spring-context-5.3.3.jar:5.3.3]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588) ~[spring-context-5.3.3.jar:5.3.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[spring-boot-2.4.2.jar:2.4.2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.4.2.jar:2.4.2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.2.jar:2.4.2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.2.jar:2.4.2]
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:123) ~[spring-boot-test-2.4.2.jar:2.4.2]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.3.3.jar:5.3.3]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-5.3.3.jar:5.3.3]
... 69 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.cloudyrock.spring.v5.MongockSpring5$Builder]: Factory method 'mongockBuilder' threw exception; nested exception is java.lang.NullPointerException: Cannot invoke "java
.util.List.iterator()" because "changeLogsScanPackage" is null
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.3.jar:5.3.3]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.3.jar:5.3.3]
... 88 common frames omitted
Caused by: java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "changeLogsScanPackage" is null
at io.changock.runner.core.builder.RunnerBuilderBase.addScanItemsFromConfig(RunnerBuilderBase.java:140) ~[changock-runner-core-1.1.11.jar:na]
at io.changock.runner.core.builder.RunnerBuilderBase.setConfig(RunnerBuilderBase.java:125) ~[changock-runner-core-1.1.11.jar:na]
at io.changock.runner.spring.v5.ChangockSpringBuilderBase.setConfig(ChangockSpringBuilderBase.java:56) ~[changock-spring-v5-runner-1.1.11.jar:na]
at io.changock.runner.spring.v5.ChangockSpringBuilderBase.setConfig(ChangockSpringBuilderBase.java:30) ~[changock-spring-v5-runner-1.1.11.jar:na]
at com.github.cloudyrock.spring.v5.MongockSpringDataCoreContextBase.mongockBuilder(MongockSpringDataCoreContextBase.java:15) ~[mongock-spring-v5-4.1.19.jar:na]
at com.github.cloudyrock.spring.v5.MongockSpringDataV3CoreContext.mongockBuilder(MongockSpringDataV3CoreContext.java:42) ~[mongock-spring-v5-4.1.19.jar:na]
at com.github.cloudyrock.spring.v5.MongockSpringDataV3CoreContext$$EnhancerBySpringCGLIB$$77ad1773.CGLIB$mongockBuilder$1(<generated>) ~[mongock-spring-v5-4.1.19.jar:na]
at com.github.cloudyrock.spring.v5.MongockSpringDataV3CoreContext$$EnhancerBySpringCGLIB$$77ad1773$$FastClassBySpringCGLIB$$9b166dc9.invoke(<generated>) ~[mongock-spring-v5-4.1.19.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.3.jar:5.3.3]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.3.jar:5.3.3]
at com.github.cloudyrock.spring.v5.MongockSpringDataV3CoreContext$$EnhancerBySpringCGLIB$$77ad1773.mongockBuilder(<generated>) ~[mongock-spring-v5-4.1.19.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.3.jar:5.3.3]
... 89 common frames omitted
是的,我确实浏览了官方文件,但没有发现任何有用的
(跟随youtube视频:链接)
如果我需要提供更多的信息,请告诉我,我真的很纠结。
我需要更多的信息来弄清楚发生了什么。
- Mongock, Spring版本
- 代码:至少你的Spring应用程序主类和属性文件
- 至少包含monock依赖项的Pom文件,以及它们是如何导入的:使用依赖管理器等。
我至少需要这个。