Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that Springboot cannot be started with test

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to solve the problem that Springboot can not start using test". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Springboot cannot be started using test

Test failed to start, encountered

Java.lang.IllegalStateException: Unable to find a @ SpringBootConfiguration, you need to use error message

Test whether the file and startup file are in the same layer directory

SpringBootTest-- trampling error

Spring boot makes it easier for us to develop spring

Using a large number of automatic configuration, we only need to make a simple basic configuration to quickly develop a spring application.

Spring also has a scenario initiator for unit testing-spring-boot-starter-test, which allows us to test in a spring environment.

During the test yesterday, the container could not be started. After inspection, I found the reason, and it was also because of my carelessness.

@ RunWith (value = SpringRunner.class) / / @ SpringBootTest (classes = SearchApplication9007Test.class) / / misspelled, this class should be filled in your main startup class, / / not your test class. I thought the slightly higher version I used before could omit the configuration in this parenthesis / /. However, this version needs to be configured with @ SpringBootTest (classes = SearchApplication9007.class) / / correctly written, and the main configuration class public class SearchApplication9007Test {@ Autowired private ElasticsearchTemplate elasticsearchTemplate; / * * "how to solve the problem that Springboot cannot be started with test" is introduced here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report