spring boot 与jpa结合的过程中出现问题,但刚接触不知道问题在哪,麻烦大神指点,十分感谢
 @Controller
public class RedisController {
    @Autowired
    private RedisStatusService redisStatusService;

    @RequestMapping("")
    public String index(HttpServletResponse response) {
        //重定向到 /index
        return response.encodeRedirectURL("/index");
    }
    @RequestMapping(value = "/showredisstutas" , method = RequestMethod.GET)
    public String addCourse(HttpServletResponse response, HttpSession session,@RequestParam(value = "ipadd") String ipadd, @RequestParam(value = "port") String port){
        Iterable<RedisStatus> list=redisStatusService.getRedisStatusInfo(ipadd,port);
        session.setAttribute("statuslist",list);

        return response.encodeRedirectURL("/showRedisStatus");
    }
}

```public class RedisStatusService {
/* @Resource
RedisStatusDao redisStutasDao;
@Resource
RedisPortInfoDao redisPortInfoDao;*/
@Autowired
private RedisPortInfoDao redisPortInfoDao;

@Autowired
private RedisStatusDao redisStutasDao;
public Iterable<RedisStatus> getRedisStatusInfo(String ip,String port){
    Iterable<RedisStatus> list=null;
    try {
        RedisPortInfo  rpi=redisPortInfoDao.findByRedis_ipAndRedis_port(ip,port);
        if(rpi!=null){
            list = new ArrayList<RedisStatus>();
            list = redisStutasDao.findByRedis_idOrderByRecoder_timeDesc(rpi.getRedis_port_id());
        }else{
            list=null;
        }
    }catch (Exception ee){
        list=null;
    }
    return list;
}

}

```public interface RedisPortInfoDao extends CrudRepository<RedisPortInfo, String> {

    public RedisPortInfo findByRedis_ipAndRedis_port(String redis_ip,String redis_port);
}


@Entity
@Table(name = "redis_port_info")
public class RedisPortInfo {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "redis_port_id")
    private int redis_port_id;
    @Column(name = "redis_ip")
    private String  redis_ip;
    @Column(name = "redis_port")
    private int  redis_port;
    @Column(name = "redis_name")
    private String redis_name;
    @Column(name = "slowlog_lastid")
    private int  slowlog_lastid;

    public int getRedis_port_id() {
        return redis_port_id;
    }

    public void setRedis_port_id(int redis_port_id) {
        this.redis_port_id = redis_port_id;
    }

    public String getRedis_ip() {
        return redis_ip;
    }

    public void setRedis_ip(String redis_ip) {
        this.redis_ip = redis_ip;
    }

    public int getRedis_port() {
        return redis_port;
    }

    public void setRedis_port(int redis_port) {
        this.redis_port = redis_port;
    }

    public String getRedis_name() {
        return redis_name;
    }

    public void setRedis_name(String redis_name) {
        this.redis_name = redis_name;
    }

    public int getSlowlog_lastid() {
        return slowlog_lastid;
    }

    public void setSlowlog_lastid(int slowlog_lastid) {
        this.slowlog_lastid = slowlog_lastid;
    }
}

以下是报错信息

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.service.RedisStatusService com.example.controller.RedisController.redisStatusService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisStatusService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.dao.RedisPortInfoDao com.example.service.RedisStatusService.redisPortInfoDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisPortInfoDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property redis found for type RedisPortInfo!
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.service.RedisStatusService com.example.controller.RedisController.redisStatusService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisStatusService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.dao.RedisPortInfoDao com.example.service.RedisStatusService.redisPortInfoDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisPortInfoDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property redis found for type RedisPortInfo!
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisStatusService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.dao.RedisPortInfoDao com.example.service.RedisStatusService.redisPortInfoDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisPortInfoDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property redis found for type RedisPortInfo!
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.example.dao.RedisPortInfoDao com.example.service.RedisStatusService.redisPortInfoDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisPortInfoDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property redis found for type RedisPortInfo!
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisPortInfoDao': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property redis found for type RedisPortInfo!
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property redis found for type RedisPortInfo!

麻烦大神帮忙找出问题

2个回答

RedisStatusService 类头部需要注入@Service,你这个明显是类未进行依赖注入。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问