Consider defining a bean of type ‘com.nclg.mall.service.AdminService‘ in your configuration.

问题描述

使用spring boot分模块开发时启动application出现错误

Consider defining a bean of type 'com.nclg.mall.service.AdminService' in your configuration.

原因

spring boot默认只扫描application启动器所在的包及其子包,分模块的包不在同一个包下

解决

指定spring boot应该扫描哪些包

@SpringBootApplication(scanBasePackages = {
    
    "com.nclg.mall.api",
        "com.nclg.mall.db","com.nclg.mall.service"})

猜你喜欢

转载自blog.csdn.net/qq_47768542/article/details/111565218