qq_25006515 2017-07-24 11:55 采纳率: 57.4%
浏览 1046

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条回答 默认 最新

  • devmiao 2017-07-24 13:19
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)