Archetype Created Web Applicationseckill-dispatcherorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:spring/spring-*.xmlseckill-dispatcher/CharacterEncodingFilterorg.springframework.web.filter.CharacterEncodingFilterencodingUTF-8CharacterEncodingFilter/*DruidStatViewcom.alibaba.druid.support.http.StatViewServletloginUserNameadminloginPassword123456DruidStatView/druid/*DruidWebStatFiltercom.alibaba.druid.support.http.WebStatFilterexclusions*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*DruidWebStatFilter/*
接下来就是测试啦!!
(1)测试mybatis与spring是否整合好:
编写我们自己的bean先
public class Score {
private Long id;
//积分变化类型
private String changeType;
//创建时间
private Date createTime;
//积分变化数
private Integer score;
//爱豆变化者
private User user;
//省略无参构造器,全参构造器,以及一系列的getset
}
(2)然后就是编写接口嘛:
public interface ScoreDao {
//插入积分记录
int insertScore(Score score);
}
@Service
public class ScoreServiceImpl implements ScoreService{
@Autowired
private ScoreDao scoreDao;
@Override
public int insertScore(Score score) {
int t =scoreDao.insertScore(score);
return t;
}
}
最后就写下controller给springmvc解析视图出来嘛。这样就整个框架测试成功啦!!!
@RestController
@RequestMapping("/test")
public class TestController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ScoreService scoreService;
@RequestMapping(value = "/testMethod",produces="text/html;charset=UTF-8", method = {RequestMethod.GET,RequestMethod.GET})
public String test() {
Score score = new Score();
score.setChangeType("玩游戏");
score.setScore(10);
scoreService.insertScore(score);
return JSON.toJSONString(score);
}
}
二、Redis单机版以及测试
(测试以查禁言表为例子)
(1)MAVEN拉下redis的库
(2)编写单机版redis配置
(3)基本业务代码先:
public interface GagDao {
public int insertGag(Gag gag);
List findByUserId(Long id);
}
GagMapper
INSERT INTO gag (gag_time,user_id)
VALUES (#{gagTime},#{user.id})
业务的接口以及实现
public interface GagService {
public int insertGag(Gag gag);
List findByUserId(Long id);
}
@Override
public List findByUserId(Long id) {
List gagList=gagDao.findByUserId(id);
return gagList;
}
Description:插入大量测试数据
use xmpl;
drop procedure if exists mockup_test_data_sp;
create procedure mockup_test_data_sp(
in number_of_records int
)
begin
declare cnt int;
declare name varch
MYSQL的随机抽取实现方法。举个例子,要从tablename表中随机提取一条记录,大家一般的写法就是:SELECT * FROM tablename ORDER BY RAND() LIMIT 1。但是,后来我查了一下MYSQL的官方手册,里面针对RAND()的提示大概意思就是,在ORDER BY从句里面不能使用RAND()函数,因为这样会导致数据列被多次扫描。但是在MYSQL 3.23版本中,