[英]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.