发表于: 2017-05-09 23:47:44
2 1149
今天完成的事:
一、服务器上安装配置redis
redis下载:http://download.redis.io/releases/
安装参考:http://blog.csdn.net/yingxiake/article/details/51469364
配置参考:http://www.cnblogs.com/wangchunniu1314/p/6339416.html(此处有巨坑,害的我今天至少装了三遍,不过注意以下几个地方就好了)
1、得将ect改成etc
2、红框中的命令语句执行不了,因为第一个文件和后面的文件不在一个目录下。第一个在utils文件夹里,后面的在src文件夹里,这里需要分别移动他们
3、脚本文件中配置文件的引用地址写错了。(装来装去最终觉得这篇比较全比较详细,把redis配置成service软启动,所以最后还是参照这篇来配置。另外建议不要在这篇教程提供的资源链接下载redis。)希望对后面的师弟有帮助
二、编写代码部署到服务器
参考:http://www.cnblogs.com/JKayFeng/p/5911544.html
public List<Student> getAllStudent() {
//获取学生列表的ID的集合
List<Integer> intList=studentDao.getStudentIdList();
List<Student> studentList=new ArrayList<Student>();
Student student;
//遍历id集合
for (Integer id:intList){
if (jedis!=null&&jedis.get(("student_"+id).getBytes())!=null){
student=(Student)serializeUtil.unserizlize(jedis.get(("student_"+id).getBytes()));
studentList.add(student);
System.out.println("从缓存中获取Student:ID="+id);
}else {
student=studentDao.getStudentById(id);
if (jedis!=null){
jedis.set(("student_"+id).getBytes(),serializeUtil.serialize(student));
}
System.out.println("从数据库中获取Student:ID="+id);
studentList.add(student);
}
}
return studentList; //返回studentList
// return studentDao.getAllStudent();
}
遇到的问题:
1、将项目部署到服务器后redis开启状态下能正常运行当我将redis关闭后程序不能自动去数据库获取数据,且抛出500错误,程序崩溃,需重启Tomcat或jetty才能重新运行
明天计划的事:将问题处理完,开始task7
总结:今天在服务器装redis浪费了太多时间,以致没将问题解决掉。
评论