springboot报错:
创建名为“”的bean时出错”cn.cyjt.shoot.service.UserServiceTests’:通过字段“service”表示的不满足的依赖关系;嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有限定类型为’cn.cyjt.shoot.service.IUSERVICE’available:至少需要1个符合autowire候选的bean。依赖项批注:{@org.springframework.beans.factory.annotation.Autowired(必需=true)}
Error creating bean with name 'cn.cyjt.shoot.service.UserServiceTests': Unsatisfied dependency expressed through field 'service'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.cyjt.shoot.service.IUserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
原因:
service依赖关系不足,在
文件里,缺少了@service依赖包。
解决方法:
import org.springframework.stereotype.Service;
@Service
public class UserServiceImpl implements IUserService{
@Autowired
private UserMapper userMapper;
@Override
public void reg(User user) {
。。。。。
。。。
。。
。#后没写