maven多模块启动required a bean of type com.xxx.xxx.service that could not be found.

Description:

Field testService in com.xxx.xxx.api.controller.TestController required a bean of type 'com.xxx.xxx.service.TestService' that could not be found.

Action:

Consider defining a bean of type 'com.xxx.xxx.service.TestService' in your configuration.

1.maven多模块启动类:

@SpringBootApplication
@SpringBootApplication(scanBasePackages = {"com.xxx.xxx.service","com.xxx.xxx.api.controller"})
@SpringBootApplication(scanBasePackages = {"com.xxx.xxx.**"})

2.TestService类加注解@Service

另外,暴力方法:

@Autowired
TestService testService;
改为
TestService testService = new TestService();
但是,这样就不归spring管理了
上一篇:Field userService in com.wuji.controller.UserController required a bean of type 'com.wuji.service.UserService' that could not be found


下一篇:自定义input默认placeholder样式