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

Description:spring

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


Action:maven

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

 

1.maven多模块启动类:ui

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

2.TestService类加注解@Serviceip

 

另外,暴力方法:io

@Autowired
TestService testService;
改成
TestService testService = new TestService();可是,这样就不归spring管理了
相关文章
相关标签/搜索