我创建了一个集成测试来测试我刚刚添加的新功能,但Spring连接不起作用.单元测试所有工作,现有的Spring集成测试仍然有效,但我无法自动连接我的新类
以下是错误消息-
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.xxx.xxx.etc.MyNewClassTest’: Unsatisfied dependency expressed through field 'sut'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xxx.xxx.etc.MyNewClass ' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
个
新班级-
@Slf4j
@Component
public class MyNewClass extends AbstractRetryJob<Event> {
我的测试-
@ExtendWith(SpringExtension.class)
class MyNewClassTest {
@Autowired private MyNewClass sut;
你知道哪里出了问题吗?