0

I have my application class defined as

@SpringBootApplication(scanBasePackages = {"com.binance.bot", "com.binance.api.client", "com.gateiobot"})
@Configuration
@EnableScheduling
public class BinancebotApplication implements CommandLineRunner {

And in my springboot test I tried to use the auto scan packages by specifying the above Application class, as:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
@EnableConfigurationProperties
public class MACDCalculationIntegrationTest {

Test fails with

Parameter 1 of constructor in com.gateiobot.macd.MACDCalculation required a bean of type 'com.binance.bot.common.Mailer' that could not be found.

Why isn't the autoscan working?

Walking Corpse
  • 107
  • 7
  • 31
  • 49
  • By default `@SpringBootApplication` has `@ComponentScan` , but can you explicitly define it ? `@ComponentScan(basePackages = {"com.whatever"})` , by default it scans in base package where your application class is defined. Can you check if explicit definition helps ? – Harsh May 30 '22 at 09:29
  • 1
    Does this answer your question? [Why component scanning does not work for Spring Boot unit tests?](https://stackoverflow.com/questions/48679637/why-component-scanning-does-not-work-for-spring-boot-unit-tests) – pringi May 31 '22 at 10:48
  • @SpringBootTest(classes=BinancebotApplication.class) did it. – Walking Corpse Jun 01 '22 at 19:58

0 Answers0