Why does SpringBootTest ComponentScan finds a bean outside of the basePackages and tries to create it?

83 Views Asked by At

I have a @SpringBootTest that use a @Configuration class with @ComponentScan:

@SpringBootTest(classes = BaseTest.Conf.class)
public class SocGenTest extends BaseTest {

And the configuration class:

public class BaseTest {

    @Configuration
    @ComponentScan(basePackages = {
            "com.capitolis.novation",
            "com.capitolis.generated",
            "com.capitolis.trade"
    },
    excludeFilters = {
            @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com.capitolis.trade.resolve.clients.*")
    })
    public static class Conf {

    }

But when I run the test it complains about a missing dependency for a component that is not in one of the scanned packages and shouldn't be created at all:

UnsatisfiedDependencyException: Error creating bean with name 'pageReplacerModelConverter'

This class is in another package:

package com.capitolis.springboot.openapi;

@Component
public class PageReplacerModelConverter extends AbstractModelConverter {
  • Anybody knows of a reason this component is being created?
  • Is there some other thing in my project that may cause my test to try load things from outside of the packages I defined?
  • Is there a way to turn on tracing of the component scan so I can maybe understand why it is trying to create this component?

Thank you

0

There are 0 best solutions below