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管理了