Spring Boot multi-module test package scan error

package structure is as follows:
com.xxx.xxx.package1
com.xxx.xxx.package2
com.xxx.xxx.package3
com.xxx.xxx.common.package1
.
each package has an independent controller,service,repository, etc.

tested in Spring Boot and JUnit5 environments, @ ComponentScan (value= {"com.xxx.xxx.package1", "com.xxx.xxx.common.package1"}) finally shows that bean cannot be injected

Mar.01,2021

spring boot does not need to display the specified @ ComponentScan

@RunWith(SpringRunner.class)
@SpringBootTest
public class ApplicationTests {

    @Test
    public void contextLoads() {
    }
}

you can refer to spring boot sample code

.

feedback if you have any questions

Menu