executeSeckill测试问题?

来源:4-1 使用集成测试Service逻辑

搬砖工学编程

2016-10-11 17:02

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'uesrphone' not found. Available parameters are [seckillId, userphone, param1, param2]


我已经加了@Param可是没用,回去发现之前Dao层中的queryByIdWithSeckill()方法也出了这个问题,在没有写Service层之前都没有出现问题,结果写完后测试发现都不行了。

写回答 关注

2回答

  • 搬砖工学编程
    2016-10-12 18:15:47

    真的是打错了!! 真是粗心!

    但是新的问题又来了 

    @Test
    public void executeSeckill() throws Exception {
       long id = 1000;
       long phone = 13877093290L;
       String  md5 = "42d56fec120bf23e3af750569ca017c3";
       SeckillExcution seckillExcution = seckillService.executeSeckill(id,phone,md5);
       logger.info("SeckillExcution={}"+seckillExcution);

    输出结果

    18:14:52.931  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Creating a new SqlSession

    18:14:52.935  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

    18:14:52.940  [main]  DEBUG o.m.s.t.SpringManagedTransaction -  JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@616ac46a] will be managed by Spring

    18:14:52.943  [main]  DEBUG o.s.dao.SeckillDao.reduceNumber -  ==>  Preparing: update seckill set number = number - 1 where seckill_id = ? and start_time <= ? and end_time >= ? and number > 0 

    18:14:52.965  [main]  DEBUG o.s.dao.SeckillDao.reduceNumber -  ==> Parameters: 1001(Long), 2016-10-12 18:14:52.923(Timestamp), 2016-10-12 18:14:52.923(Timestamp)

    18:14:52.973  [main]  DEBUG o.s.dao.SeckillDao.reduceNumber -  <==    Updates: 1

    18:14:52.973  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

    18:14:52.974  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff] from current transaction

    18:14:52.974  [main]  DEBUG o.s.d.S.insertSuccessKilled -  ==>  Preparing: insert ignore into success_killed (seckill_id,user_phone) value (?,?) 

    18:14:52.975  [main]  DEBUG o.s.d.S.insertSuccessKilled -  ==> Parameters: 1001(Long), 13877093293(Long)

    18:14:52.983  [main]  DEBUG o.s.d.S.insertSuccessKilled -  <==    Updates: 1

    18:14:52.983  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

    18:14:52.984  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff] from current transaction

    18:14:52.985  [main]  DEBUG o.s.d.S.queryByIdWithSeckill -  ==>  Preparing: select sk.seckill_id, sk.user_phone, sk.create_time, sk.state, s.seckill_id "seckill.seckill_id", s.name "seckill.name", s.number "seckill.number", s.start_time "seckill.start_time", s.end_time "seckill.end_time", s.create_time "seckill.create_time" from success_killed sk inner join seckill s on sk.seckill_id = s.seckill_id where sk.seckill_id = ? and sk.user_phone = ? 

    18:14:52.985  [main]  DEBUG o.s.d.S.queryByIdWithSeckill -  ==> Parameters: 1001(Long), 13877093293(Long)

    18:14:53.002  [main]  DEBUG o.s.d.S.queryByIdWithSeckill -  <==      Total: 1

    18:14:53.006  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

    18:14:53.007  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

    18:14:53.007  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

    18:14:53.007  [main]  DEBUG org.mybatis.spring.SqlSessionUtils -  Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b3f61ff]

    18:14:53.098  [main]  INFO  o.seckill.service.SeckillServiceTest -  SeckillExcution={}org.seckill.dto.SeckillExcution@1672fe87

    为什么SeckillExcution ={} 里面没有信息的?

  • 龙王丨
    2016-10-12 10:48:17

    uesrphone -> userphone,  看看是不是因为单词拼错了的原因

Java高并发秒杀API之Service层

Java实现高并发秒杀API,介绍秒杀业务Service层的设计和实现

59897 学习 · 137 问题

查看课程

相似问题