qq_39569024
2021-09-13 22:26
采纳率: 73.9%
浏览 30
已结题

求解这个错误是啥原因

就一个实体类,一个测试类

@Data
@Entity
@Table(name="hanma_seller")
@Proxy(lazy = false)
public class SellerInfo {
    @Id
    private String sellerId;
    private String username;
    private String password;
    private String openid;
}
```java
@RunWith(SpringRunner.class)
@SpringBootTest
public class SellerInfoTest {
    @Autowired
    private SellerInfoRepository repository;
    @Test
    public void saveTest(){
        SellerInfo sellerInfo=new SellerInfo();
        sellerInfo.setSellerId(KeyUtil.getUniqueKey());
        sellerInfo.setUsername("admin");
        sellerInfo.setPassword("admin");
        sellerInfo.setOpenid("abcd");
        SellerInfo result=repository.save(sellerInfo);
        Assert.assertNotNull(result);
    }
    @Test
    public void findTest(){
        SellerInfo result=repository.findByOpenid("abcd");
        Assert.assertEquals("abcd",result.getOpenid());
    }
}


报错:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.example.jingdong.SellerInfoTest': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.jingdong.repository.SellerInfoRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题