springboot 多模块中service注入不了的问题

controller中注入service的接口,但是总是提示找不到这个bean,查了很多资料,主要的原因就是没有扫描到

多模块要注意的东西就是启动类@ComponentScan的注解,看下启动类所在包是不是和所依赖的service接口同一基础包之下,如果不在就加上扫描的service的 基础包

 

@SpringBootApplication
@ServletComponentScan
@ComponentScan("com.szsg.generic.core")
@MapperScan("com.szsg.generic.core.dao")
public class AdminApplication {

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

}

 

你可能感兴趣的:(框架,java)