初始化错误:无法找到@SpringBootConfiguration

截至昨天,我的所有测试都在运行,现在我的扩展 BaseSpringBootTest 类的测试失败了。


测试应用程序类


@SpringBootTest

//@PropertySource(value = "classpath*:override.properties", ignoreResourceNotFound = true)

//@ImportResource("classpath*:applicationContext.xml")

@ComponentScan("com.myorg")

public class TestApplication {


    public static void main(String[] args) {

        SpringApplication.run(TestApplication.class, args);

    }

}

BaseSpringBootTest.class


@RunWith(SpringRunner.class)

@SpringBootTest()

@ActiveProfiles("test")

public abstract class BaseSpringBootTest {

  @Resource protected DomainOntology domainOntology;


  @Before

  public void before() throws InterruptedException, JAXBException, IOException {

    domainOntology.initializeCacheIfNeeded();

    ;

  }

}

测试抛出错误


public class CacheFormatterTest extends BaseSpringBootTest {

    @Resource

    CacheFormatter cf;

    SpelEvaluator spel = new SpelEvaluator();


    @Test

    public void testFormatWithMockedRecordGenerator() throws IOException {


我期望它能够达到并运行此测试,但它似乎无法初始化。它昨天还在运行,我似乎不知道是什么让它停止了。


守着星空守着你
浏览 66回答 1
1回答

catspeake

找到我的 @SpringBootApplication 类时遇到问题,我继续将该类移动到根目录中,因为它正在我的测试包上方的包中查找它。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java