Я пытаюсь придать пружинную фасоль в TestNG @BeforeClass, но он показывает следующее сообщение об ошибке:TestNG и весна интеграция
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.tais.automation.service.ExecutionDetailManager com.tais.automation.testing.Driver.executionDetailManager; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'executionDetailManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.tais.automation.service.impl.ExecutionDetailManagerImpl.setConvertUtils(com.tais.automation.util.ConvertUtils); nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'convertutils': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.tais.automation.dao.ClientDao com.tais.automation.util.ConvertUtils.clientDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Resource(shareable=true, mappedName=, description=, name=, type=class java.lang.Object, lookup=, authenticationType=CONTAINER)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289) ... 125 more
@ContextConfiguration(locations="classpath*:/applicationContext.xml")
public class Driver extends AbstractTransactionalTestNGSpringContextTests {
@Autowired
ExecutionDetailManager executionDetailManager;
@Override
@BeforeSuite(alwaysRun=true)
protected void springTestContextPrepareTestInstance() throws Exception {
super.springTestContextBeforeTestClass();
super.springTestContextPrepareTestInstance();
}
@Parameters({ "Module"})
public void setUp(@Optional("") String varModule) throws Exception {
//At this point my code breaks
String result=**executionDetailManager.getResult();**
}
}
public interface ExecutionDetailManager {
public String getResult();
}
@Service("executionDetailManager")
public class ExecutionDetailManagerImpl implements ExecutionDetailManager
{
public String getResult() {
return "testResult";
}
}
вы видите этот 'org.springframework.beans.factory.NoSuchBeanDefinitionException: Нет квалификации bean типа [org.hibernate.SessionFactory], найденного для зависимостей: ожидается как минимум 1 компонент, который квалифицируется как кандидат autwire для этой зависимости. Аннотации зависимостей: ' – SMA
@ vogel612 Вышеупомянутая проблема решена noe, она показывает NoSuchBeanDefinitionException для выполненияDetailManager ?? –