Java 加载ApplicationContext失败,无法创建所有bean
我可以运行我的项目,并运行它没有错误。但当我运行测试时,它无法运行。Java 加载ApplicationContext失败,无法创建所有bean,java,spring,spring-boot,spring-mvc,spring-boot-test,Java,Spring,Spring Boot,Spring Mvc,Spring Boot Test,我可以运行我的项目,并运行它没有错误。但当我运行测试时,它无法运行。 我一步一步地查看文档和文档。 我不知道我在哪里犯错误 配置: @EnableScheduling @SpringBootApplication @EnableAsync @EnableTransactionManagement(proxyTargetClass = true) @EnableCaching @MapperScan(basePackages = {"com.cybertron.*.service.dao",
我一步一步地查看文档和文档。
我不知道我在哪里犯错误 配置:
@EnableScheduling
@SpringBootApplication
@EnableAsync
@EnableTransactionManagement(proxyTargetClass = true)
@EnableCaching
@MapperScan(basePackages = {"com.cybertron.*.service.dao",
"com.cybertron.service.auth.dao","com.cybertron.service.mes.api.dao"})
public class CybertronMpsApplication {
public static void main(String[] args) {
SpringApplication.run(CybertronMpsApplication.class, args);
}
}
测试文件
@RunWith(SpringRunner.class)
@AutoConfigureMockMvc
@Transactional
@SpringBootTest
@ActiveProfiles("test")
//@ContextConfiguration(classes = TestConfig.class)
public class DeliveryOrderControllerTest {
@Autowired
private MockMvc mockMvc;
@Test
public void generateInvoiceInfo() throws Exception {
RequestBuilder requestBuilder = MockMvcRequestBuilders.get("/order/insert/generateInvoiceInfo")
.param("deliveryOrderId", "2499");
mockMvc.perform(requestBuilder);
}
}
错误消息:
java.lang.IllegalStateException:未能加载ApplicationContext
位于org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
位于org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83)
位于org.springframework.test.context.web.ServletTestExecutionListener.SetupRequestContextIfNeeded(ServletTestExecutionListener.java:189)
位于org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:131)
位于org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230)
位于org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228)
位于org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287)
位于org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
位于org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289)
位于org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247)
位于org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
位于org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
位于org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
位于org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
访问org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
位于org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
位于org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
位于org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
位于org.junit.runners.ParentRunner.run(ParentRunner.java:363)
位于org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
位于org.junit.runner.JUnitCore.run(JUnitCore.java:137)
位于com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
位于com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
位于com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
位于com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
原因:org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“asyncApsTask”的bean时出错:通过字段“mpsRecordService”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.unsatifiedpendencyException:创建名为“recordService”的bean时出错:通过字段“stockService”表示未满足的依赖关系;嵌套异常为org.springframework.beans.factory.unsatifiedpendencyException:创建名为“mdStockService”的bean时出错:未满足的依赖项通过字段“MPProductService”表示;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“MPProductServiceImpl”的bean时出错:通过字段“warehouseService”表示未满足的依赖关系;嵌套异常为org.springframework.beans.factory.unsatifiedpendencyException:创建名为“mwarehouseService”的bean时出错:通过字段“storageLocationService”表示未满足的依赖关系;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“storageLocationServiceImpl”的bean时出错:通过字段“storageLocationRecordService”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“storageLocationRecordServiceImpl”的bean时出错:通过字段“OutingStorageLockService”表示的未满足的依赖项;嵌套异常为org.springframework.beans.factory.UnsatifiedPendencyException:创建名为“OutingStorageLockServiceImpl”的bean时出错:通过字段“ExpectOutingVentoryEntityService”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“expectOutInventoryEntityServiceImpl”的bean时出错:通过字段“relationService”表示的未满足的依赖项;嵌套异常为org.springframework.beans.factory.unsatifiedPendencyException:创建名为“DDeliveryOrderAPlanRelationServiceImpl”的bean时出错:通过字段“deliveryOrderlineService”表示的未满足的依赖项;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“deliveryOrderlineServiceImpl”的bean时出错:通过字段“deliveryOrderService”表示的未满足的依赖项;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“deliveryOrderServiceImpl”的bean时出错:通过字段“productRecordItemService”表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.UnsatifiedPendencyException:创建名为“productRecordItemService”的bean时出错:通过字段“machineWorkCalendarService”表示未满足的依赖关系;嵌套异常为org.springframework.beans.factory.unsatifiedpendencyException:创建名为“MachineWorkCalendarService”的bean时出错:通过字段“machineService”表示未满足的依赖关系;嵌套的异常是org.springfram
* Annotation that can be specified on a test class that runs Spring Boot based tests.
* Provides the following features over and above the regular <em>Spring TestContext
* Framework</em>:
* <ul>
* <li>Uses {@link SpringBootContextLoader} as the default {@link ContextLoader} when no
* specific {@link ContextConfiguration#loader() @ContextConfiguration(loader=...)} is
* defined.</li>