0
我有以下代碼:@ComponentScan將不起作用
豆的執行情況:
package my.persist.services;
@Component
public class MyService{
}
測試:
package my.persist.services;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={"other configuration classes", my.persist.services.MyService.class})
@ComponentScan(basePackageClasses = {my.persist.services.DummyPlaceHolder.class})
public class MyServiceTest extends AbstractJUnit4SpringContextTests {
@Autowired
MyService service;
}
當我刪除「my.persist.services。我的服務類「從@ContextConfiguration
,編譯器說:」不能自動裝配,沒有找到...的豆「,它似乎是@ComponentScan
有沒有影響?任何幫助?