我尝试使用Spring Boot对我的DAO层进行测试。但是我收到
java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.example.demo.FoodDaoIntegrationTest]
我已经读过几个关于此错误的答案,但仍然没有帮助。我猜注释仍然存在某种问题。 我的测试是:
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() {
答案 0 :(得分:0)
注释中出现混乱。您不能混合使用SpringBootTest和DataJpaTest
尝试一下:
@RunWith(SpringRunner.class)
@DataJpaTest
public class FoodDaoIntegrationTest {