In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to solve SpringBoot running Test Times error: SpringBoot Unable to find". In daily operation, I believe many people have doubts about how to solve SpringBoot running Test Times error: SpringBoot Unable to find problem. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for everyone to answer "how to solve SpringBoot running Test Times error: SpringBoot Unable to find"! Next, please follow the editor to study!
Catalogue
SpringBoot running Test Times error
Error details
Solution.
SpringBootTest unit test error report
SpringBoot running Test Times error
Error message when running Test: SpringBoot Unable to find a @ SpringBootConfiguration
Error details
Today, when you do SpringBoot to configure email delivery, run the test class and report the following error:
Said that can not find the @ SpringBootConfiguration annotation, in fact, there is, checked the startup class and the details of the class under test, no problem, a lot of CSDN answers are to copy each other. For example, the package name of the test class is the same as that of the startup class, but it is useless to try.
Solution.
It turns out that the startup class has to be developed in the test class. The solution is simple: change the @ SpringBootTest () annotation to @ SpringBootTest (classes = App.class). It's like this:
Note: my startup class here is called App. When you change it, change it according to your own startup class name.
SpringBootTest unit test error @ RunWith (SpringRunner.class) @ SpringBootTest (classes = {DataRulesApplication.class}) @ EnableAutoConfiguration//@SpringBootTest (classes = {DataRulesApplication.class}) public class HuaboAddressTest extends AbstractTestNGSpringContextTests {@ Autowired private HuaboAddressServiceImpl johnyService; @ Test public void queryState () {/ / johnyService.resetAllDistricts (); long startTime = System.currentTimeMillis (); / / johnyService.resetAllDistricts (); / / johnyService.batchUpdate2 () / / johnyService.batchupdate3 (); / / johnyService.resetAllDistricts (); johnyService.updateBatch (); long endTime = System.currentTimeMillis (); System.out.println ("execution time:" + (endTime-startTime)); / / long startTime = System.currentTimeMillis (); / / johnyService.select1 (); / / long endTime = System.currentTimeMillis () / / System.err.println ("execution time 1:" + (endTime-startTime)); / / startTime = System.currentTimeMillis (); / / johnyService.select2 (); / / endTime = System.currentTimeMillis (); / / System.err.println ("execution time 2:" + (endTime-startTime)) @ Test public void check () {} @ Test public void register () {} @ Test public void detail () {} @ Test public void queryCategory () {}}
In fact, you only need to set up the environment in which test is running in setting.
At this point, the study on "how to solve SpringBoot running Test Times error: SpringBoot Unable to find" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.