Sign in

Springboot multi module project could not find the corresponding class

lxkhe edited in Sun, 02 Oct 2022

The directory structure of the project is as follows:

The corresponding main startup class code is as follows:

public class DubboServer01Application {

    public static void main(String[] args) {
        SpringApplication.run(DubboServer01Application.class, args);


Because the package name is "com" . example” , So it's not added @ Componentscan annotation, and finally start to report an error :

The @ service annotation has been added to the corresponding class:

@Service(version = "1.0.0",timeout = 10000,interfaceClass = INews.class)
public class NewsImpl implements INews {

    public Object getDailyNews() {
        return "xinwen...";
2 Replies
commented on Sun, 02 Oct 2022

1. Check whether the project of the next startup class has reference dependency on other module projects (see whether the classpath of the startup project depends on a comprehensive package); 2. If the dependency is OK, check whether the subproject is configured with automatic configuration class scanning (see the spring.factories Set org.springframework.boot . autoconfigure.EnableAutoConfiguration Value).

commented on Sun, 02 Oct 2022

If you don't specify registration for component scanning, will you only scan the components of your own module by default and not scan the packages under the same package name of other modules? Explicitly specify the basic package to scan.