因此,我有以下两个Java测试类:
package com.company.alfresco;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = BuildFileTreeApplication.class)
@Slf4j
public class BuildFileTreeTest {
@Autowired
private CmisDao cmisDao;
@Autowired
private AlfrescoFileTreeAPI alfrescoFileTreeAPI;
...
}
和
package com.company.facade;
@SpringBootTest
@Slf4j
public class EntryPointTest extends AbstractTestNGSpringContextTests{
private Map<String, String> documentMetadata;
@Autowired
private FacadeInitializer facadeInitializer;
...
}
我还有两个单独的主要方法类,每个测试类都使用一个:
package com.company;
@SpringBootApplication
@ComponentScan(basePackages = {"com.company", "com.company.ssh", "com.company.camel",
"com.company.cmis.services", "com.company.facade"})
public class AlfrescoApiApplication {
public static void main(String[] args){
SpringApplication.run(AlfrescoApiApplication.class, args);
}
}
和
package com.company;
@SpringBootApplication
@ComponentScan(basePackages = {"com.company.alfresco", "com.company.models",
"com.company.config"})
public class BuildFileTreeApplication {
public static void main(String[] args){
SpringApplication.run(BuildFileTreeApplication.class, args);
}
}
我想运行第一个测试(BuildFileTreeTest
),而不使用另一个测试正在使用的bean(FacadeInitializer
)。
由于某种原因,使用此程序包设置,当我运行BuildFileTreeTest
测试类时,FacadeInitializer
bean仍在应用程序上下文中使用,尽管它存在于“ facade”程序包中,我没有将其包含在@ComponentScan
spring main方法类的BuildFileTreeApplication
批注中。有什么想法吗?
答案 0 :(得分:0)
您可以排除具有类型,注释等的bean。
SessionFactory