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管理了
相關文章
相關標籤/搜索