簡體   English   中英

DAO 層測試:java.lang.IllegalStateException:配置錯誤:為測試類找到多個@BootstrapWith 聲明

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

我嘗試使用 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() {

你的注釋混亂。 您不能混合使用 SpringBootTest 和 DataJpaTest

嘗試這個:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM