我有一个带有接口没有实现属性的数据成员的类, 如何定义这个属性?Spring定义接口没有实现的属性
我试图与@Autowired
,但是当我在JUnit运行它 - 它抛出一个异常:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [bean name] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
//my class is :
@Service
@Component(value="someClass")
@Transactional
public class someClass implements SomeService, InitializingBean {
@Autowired
private SomeInterface someInterface ;
}
//and the interface with no implementation:
public interface SomeInterface extends CrudRepository<AAA, String> {
}
您必须配置或创建一个bean。你能展示更多的代码吗? – Patrick
我附上我的代码 – riv