简体   繁体   English

DAO 层测试:java.lang.IllegalStateException:配置错误:为测试类找到多个@BootstrapWith 声明

[英]DAO Layer test: java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class

I try to run test for my DAO Layer with Spring Boot.我尝试使用 Spring Boot 为我的 DAO 层运行测试。 But I receive java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.example.demo.FoodDaoIntegrationTest]但我收到java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.example.demo.FoodDaoIntegrationTest]

I've read a couple of answers to this error, but it still hasn't helped.我已经阅读了有关此错误的几个答案,但仍然没有帮助。 I guess there is still some kind of problem with annotations.我想注释仍然存在某种问题。 My test is:我的测试是:

package com.example.demo;
@RunWith(SpringRunner.class) @DataJpaTest
@SpringBootTest(classes = com.project.application.DemoApplication.class) 
@ContextConfiguration(classes = com.project.application.DemoApplication.class) 
public class FoodDaoIntegrationTest  {

@Autowired
private TestEntityManager entityManager;

@Autowired
private FoodDao mealDao;

@Test
public void TestSomething() {

You have a chaos in your annotations.你的注释混乱。 You can't mix SpringBootTest and DataJpaTest您不能混合使用 SpringBootTest 和 DataJpaTest

Try this:尝试这个:

@RunWith(SpringRunner.class) 
@DataJpaTest
public class FoodDaoIntegrationTest  {

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 java.lang.IllegalStateException:配置错误:为测试类找到了@BootstrapWith的多个声明 - java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class 获取 java.lang.IllegalStateException:在 Spring 启动中执行测试 class 时检测到 Logback 配置错误 - Getting java.lang.IllegalStateException: Logback configuration error detected while executing Test class in Spring boot Spring boot 1.4 测试:配置错误:发现@BootstrapWith 的多个声明 - Spring boot 1.4 Testing : Configuration error: found multiple declarations of @BootstrapWith Spring boot 2.2.0 测试:配置错误:发现@BootstrapWith的多个声明 - Spring boot 2.2.0 Testing : Configuration error: found multiple declarations of @BootstrapWith 发现多个@BootstrapWith 声明 - found multiple declarations of @BootstrapWith Spring JPA测试java.lang.IllegalStateException - Spring JPA Test java.lang.IllegalStateException 获取 java.lang.IllegalStateException: Logback 配置错误检测到错误 - Getting java.lang.IllegalStateException: Logback configuration error detected error 测试失败:java.lang.IllegalStateException:加载ApplicationContext失败 - Test Failure : java.lang.IllegalStateException: Failed to load ApplicationContext java.lang.IllegalStateException:无法加载 CacheAwareContextLoaderDelegate 单元测试 spring - java.lang.IllegalStateException: Could not load CacheAwareContextLoaderDelegate unit test spring 测试 java.lang.IllegalStateException: 加载 ApplicationContext 失败 - Test java.lang.IllegalStateException: Failed to load ApplicationContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM