SpringBoot +Redis +RabbitMQ 實現高並發限時秒殺


1.安裝RabbitMQ

docker安裝:https://blog.csdn.net/qq_33612228/article/details/103732890

windows安裝:https://blog.csdn.net/m0_37034294/article/details/82839494

2.安裝Redis

docker安裝:https://blog.csdn.net/qq_33612228/article/details/10360918

windows安裝:https://blog.csdn.net/qq_39135287/article/details/82686837

springboot整合redis:https://blog.csdn.net/qq_33612228/article/details/103700543

3.安裝 Jmeter測試工具

windows安裝:https://blog.csdn.net/liuyanh2006/article/details/82494548

4.數據庫設計

     1.商品庫存表:stock表

CREATE TABLE `stock` (
  `id` varchar(64) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `stock` varchar(255) DEFAULT NULL,
  `remarks` varchar(255) NOT NULL DEFAULT '' COMMENT '備注',
  `update_date` datetime DEFAULT NULL COMMENT '最后更新時間',
  `create_date` datetime DEFAULT NULL COMMENT '創建時間',
  `update_by` varchar(64) NOT NULL DEFAULT '',
  `create_by` varchar(64) NOT NULL DEFAULT '',
  `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '0正常,1刪除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='商品庫存表';
View Code

2.秒殺訂單表:t_order表

CREATE TABLE `t_order` (
  `id` varchar(64) NOT NULL,
  `order_name` varchar(255) DEFAULT NULL,
  `order_user` varchar(255) DEFAULT NULL,
  `remarks` varchar(255) NOT NULL DEFAULT '' COMMENT '備注',
  `update_date` datetime DEFAULT NULL COMMENT '最后更新時間',
  `create_date` datetime DEFAULT NULL COMMENT '創建時間',
  `update_by` varchar(64) NOT NULL DEFAULT '',
  `create_by` varchar(64) NOT NULL DEFAULT '',
  `del_flag` char(1) NOT NULL DEFAULT '0' COMMENT '0正常,1刪除',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='秒殺訂單表';
View Code

5.代碼層

   1.pom引入

       <!--redis-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <!--RabbitMQ-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
View Code

 2.配置application.yml

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
    username: root
    password: root1234
    # 使用Druid數據源
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    druid:
      filters: stat
      maxActive: 20
      initialSize: 1
      maxWait: 60000
      minIdle: 1
      timeBetweenEvictionRunsMillis: 60000
      minEvictableIdleTimeMillis: 300000
      validationQuery: select 'x'
      testWhileIdle: true
      testOnBorrow: false
      testOnReturn: false
      poolPreparedStatements: true
      maxOpenPreparedStatements: 20
  data:
    redis:
      repositories:
        enabled: false
  redis:
    database: 0   # redis數據庫索引(默認為0),我們使用索引為其他(0-15)的數據庫,避免和其他數據庫沖突
    host: 127.0.0.1
    port: 6379
    password: 12345678
  rabbitmq:  #mq配置
    host: 127.0.0.1
    port: 5672
    username: guest
    password: guest
server:
  port: 8090
logging:
  config: classpath:logback-spring.xml

 3.實體類 Order.java

package com.example.demo.entity;
 
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
 
/**
 * @author LST
 * @version 1.0
 * @Description: 訂單
 * @date 2019-12-27 15:54
 */
@TableName("t_order")
@Data
public class Order extends BasePlusEntity<Order>{
    private static final long serialVersionUID = 1L;
 
    /**
     * 訂單名稱
     */
    @TableField("order_name")
    private String orderName;
 
 
    /**
     * 訂單用戶
     */
    @TableField("order_user")
    private String orderUser;
 
}
View Code

Stock 商品庫存表

package com.example.demo.entity;
 
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
 
/**
 * @author LST
 * @version 1.0
 * @Description: 商品庫存表
 * @date 2019-12-27 15:54
 */
@TableName("stock")
@Data
public class Stock extends BasePlusEntity<Stock>{
    private static final long serialVersionUID = 1L;
 
    /**
     * 產品名稱
     */
    @TableField("name")
    private String name;
 
 
    /**
     * 存貨
     */
    @TableField("stock")
    private String stock;
 
}
View Code

4.服務層

StockService存貨服務層

package com.example.demo.service;
 
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.entity.Stock;
 
/**
 * @author lst
 * @version 1.0
 * @Description: 存貨服務層
 * @date 2019-12-27 15:54
 */
public interface StockService extends IService<Stock> {
    /**
     * 秒殺商品后-減少庫存
     * @param name 商品名稱
     */
    void decrByStock(String name);
 
    /**
     * 秒殺商品前判斷是否有庫存
     * @param name 商品名稱
     * @return
     */
    Integer selectByName(String name);
 
    /**
     * 實現純數據庫操作實現秒殺操作
     * @param userName 用戶名稱
     * @param stockName 商品名稱
     * @return String
     */
    String secDataBase(String userName,String stockName);
}
OrderService訂單服務層
package com.example.demo.service;
 
import com.baomidou.mybatisplus.extension.service.IService;
import com.example.demo.entity.Order;
 
/**
 * @author lst
 * @version 1.0
 * @Description: 訂單服務層
 * @date 2019-12-27 15:54
 */
public interface OrderService extends IService<Order> {
    /**
     * 訂單保存
     * @param order 實體
     */
    void saveOrder(Order order);
 
}
View Code

OrderServiceImpl訂單實現層

package com.example.demo.service.impl;
 
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Order;
import com.example.demo.exception.SXException;
import com.example.demo.exception.ServiceExceptionEnum;
import com.example.demo.mapper.OrderMapper;
import com.example.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
/**
 * @author lst
 * @version 1.0
 * @Description: 訂單實現層
 * @date 2019-12-27 15:54
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService {
 
    @Autowired
    private OrderMapper orderMapper;
 
    /**
     * 訂單保存
     * @param order 實體
     */
    @Override
    public void saveOrder(Order order) {
        if(orderMapper.insert(order) <= 0){
            throw new SXException(ServiceExceptionEnum.DATA_INSERT_EXCEPTION);
        }
    }
}
View Code

StockServiceImpl存貨實現層

package com.example.demo.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.Order;
import com.example.demo.entity.Stock;
import com.example.demo.mapper.StockMapper;
import com.example.demo.service.OrderService;
import com.example.demo.service.StockService;
import com.example.demo.utils.IdGenerate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
import java.util.List;
 
/**
 * @author lst
 * @version 1.0
 * @Description: 存貨實現層
 * @date 2019-12-27 15:54
 */
@Service
@Slf4j
public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements StockService {
 
    @Autowired
    private StockMapper stockMapper;
 
    @Autowired
    private OrderService orderService;
 
    /**
     * 秒殺商品后-減少庫存
     * @param name 商品名稱
     */
    @Override
    public void decrByStock(String name) {
        List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().lambda().eq(Stock::getName, name));
        stockList.forEach(stock -> {
            //貨物購買
            stock.setStock(String.valueOf(Integer.parseInt(stock.getStock())-1));
            stockMapper.updateById(stock);
        });
    }
 
    /**
     * 秒殺商品前判斷是否有庫存
     * @param name 商品名稱
     * @return
     */
    @Override
    public Integer selectByName(String name) {
        //查詢存貨數量
        Integer stockNum = 0;
        List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().lambda().eq(Stock::getName, name));
        if(stockList.size() > 0){
            stockNum = Integer.parseInt(stockList.get(0).getStock());
        }
        return stockNum;
    }
 
    /**
     * 實現純數據庫操作實現秒殺操作
     * @param userName 用戶名稱
     * @param stockName 商品名稱
     * @return String
     */
    @Override
    public String secDataBase(String userName, String stockName) {
        log.info("參加秒殺的用戶是:{},秒殺的商品是:{}", userName, stockName);
        String message = null;
        //查找該商品庫存
        Integer stockCount = selectByName(stockName);
        log.info("用戶:{}參加秒殺,當前商品庫存量是:{}", userName, stockCount);
        if (stockCount > 0) {
            /**
             * 還有庫存,可以進行繼續秒殺,庫存減一,下訂單
             */
            //1、庫存減一
            decrByStock(stockName);
            //2、下訂單
            Order order = new Order();
            order.setOrderUser(userName);
            order.setOrderName(stockName);
            order.setCreateBy(userName);
            order.setCreateDate(new Date());
            order.setUpdateBy(userName);
            order.setUpdateDate(new Date());
            order.setDelFlag("0");
            order.setId(IdGenerate.generateId());
            orderService.saveOrder(order);
            log.info("用戶:{}.參加秒殺結果是:成功", userName);
            message = userName + "參加秒殺結果是:成功";
        } else {
            log.info("用戶:{}.參加秒殺結果是:秒殺已經結束", userName);
            message = userName + "參加秒殺活動結果是:秒殺已經結束";
        }
        return message;
    }
}
View Code

5.配置rabbitmq的實現方式以及redis的實現方式

  1)在 service包下面直接新建 MQOrderServiceImpl.java,這個類屬於訂單的消費隊列。

package com.example.demo.service.impl;
 
import com.example.demo.config.RabbitMqConfig;
import com.example.demo.entity.Order;
import com.example.demo.service.OrderService;
import com.example.demo.utils.IdGenerate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
 
/**
 * @author lst
 * @version 1.0
 * @Description: MQ訂單實現層
 * @date 2019-12-27 15:54
 */
@Service
@Slf4j
public class MQOrderServiceImpl {
 
    @Autowired
    private OrderService orderService;
 
    /**
     * MQ監聽訂單消息隊列,並消費
     * @param order
     */
    @RabbitListener(queues = RabbitMqConfig.ORDER_QUEUE)
    public void saveOrder(Order order) {
        log.info("收到訂單消息,訂單用戶為:{},商品名稱為:{}", order.getOrderUser(), order.getOrderName());
        /**
         * 調用數據庫orderService創建訂單信息
         */
        order.setCreateBy(order.getOrderUser());
        order.setCreateDate(new Date());
        order.setUpdateBy(order.getOrderUser());
        order.setUpdateDate(new Date());
        order.setDelFlag("0");
        order.setId(IdGenerate.generateId());
        orderService.saveOrder(order);
    }
}
View Code

2)MQStockServiceImpl.java這個屬於庫存得消費隊列。

package com.example.demo.service.impl;
 
import com.example.demo.config.RabbitMqConfig;
import com.example.demo.entity.Order;
import com.example.demo.service.StockService;
import com.example.demo.utils.IdGenerate;
import com.example.demo.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.Date;
 
/**
 * @author lst
 * @version 1.0
 * @Description: MQ存貨實現層
 * @date 2019-12-27 15:54
 */
@Service
@Slf4j
public class MQStockServiceImpl {
 
    @Autowired
    private StockService stockService;
 
    @Autowired
    private RabbitTemplate rabbitTemplate;
 
    @Autowired
    private RedisUtil redisUtil;
 
 
    /**
     * 秒殺商品后-減少庫存
     * @param name 商品名稱
     */
    @RabbitListener(queues = RabbitMqConfig.STORY_QUEUE)
    public void decrByStock(String name) {
        log.info("庫存消息隊列收到的消息商品信息是:{}", name);
        /**
         * 調用數據庫service給數據庫對應商品庫存減一
         */
        stockService.decrByStock(name);
    }
 
    /**
     * 使用redis+消息隊列進行秒殺實現
     * @param userName 用戶名稱
     * @param stockName 商品名稱
     * @return String
     */
    public String secKill(String userName,String stockName) {
        log.info("參加秒殺的用戶是:{},秒殺的商品是:{}", userName, stockName);
        String message = "";
        //調用redis給相應商品庫存量減一
        Long decrByResult = redisUtil.decrBy(stockName);
        if (decrByResult >= 0) {
            /**
             * 說明該商品的庫存量有剩余,可以進行下訂單操作
             */
            log.info("用戶:{}秒殺該商品:{}庫存有余,可以進行下訂單操作", userName, stockName);
            //發消息給庫存消息隊列,將庫存數據減一
            rabbitTemplate.convertAndSend(RabbitMqConfig.STORY_EXCHANGE, RabbitMqConfig.STORY_ROUTING_KEY, stockName);
 
            //發消息給訂單消息隊列,創建訂單
            Order order = new Order();
            order.setOrderName(stockName);
            order.setOrderUser(userName);
            rabbitTemplate.convertAndSend(RabbitMqConfig.ORDER_EXCHANGE, RabbitMqConfig.ORDER_ROUTING_KEY, order);
            message = "用戶" + userName + "秒殺" + stockName + "成功";
        } else {
            /**
             * 說明該商品的庫存量沒有剩余,直接返回秒殺失敗的消息給用戶
             */
            log.info("用戶:{}秒殺時商品的庫存量沒有剩余,秒殺結束", userName);
            message = "用戶:"+ userName + "商品的庫存量沒有剩余,秒殺結束";
        }
        return message;
    }
 
}
View Code

6.RabbitMqConfig 和redisUtil工具類

  1.RabbitMqConfig.java

package com.example.demo.config;
 
import org.springframework.amqp.core.*;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
 
/**
 * @author LST
 * @version 1.0
 * @Description: RabbitMQConfig插件配置
 * @date 2019-12-27 16:23
 */
@Configuration
public class RabbitMqConfig {
    //庫存交換機
    public static final String STORY_EXCHANGE = "STORY_EXCHANGE";
 
    //訂單交換機
    public static final String ORDER_EXCHANGE = "ORDER_EXCHANGE";
 
    //庫存隊列
    public static final String STORY_QUEUE = "STORY_QUEUE";
 
    //訂單隊列
    public static final String ORDER_QUEUE = "ORDER_QUEUE";
 
    //庫存路由鍵
    public static final String STORY_ROUTING_KEY = "STORY_ROUTING_KEY";
 
    //訂單路由鍵
    public static final String ORDER_ROUTING_KEY = "ORDER_ROUTING_KEY";
 
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
 
    /**
     * 創建庫存交換機
     * @return
     */
    @Bean
    public Exchange getStoryExchange() {
        return ExchangeBuilder.directExchange(STORY_EXCHANGE).durable(true).build();
    }
 
    /**
     * 創建庫存隊列
     * @return
     */
    @Bean
    public Queue getStoryQueue() {
        return new Queue(STORY_QUEUE,true);
    }
 
    /**
     * 庫存交換機和庫存隊列綁定
     * @return
     */
    @Bean
    public Binding bindStory() {
        return BindingBuilder.bind(getStoryQueue()).to(getStoryExchange()).with(STORY_ROUTING_KEY).noargs();
    }
 
    /**
     * 創建訂單隊列
     * @return
     */
    @Bean
    public Queue getOrderQueue() {
        return new Queue(ORDER_QUEUE);
    }
 
    /**
     * 創建訂單交換機
     * @return
     */
    @Bean
    public Exchange getOrderExchange() {
        return ExchangeBuilder.directExchange(ORDER_EXCHANGE).durable(true).build();
    }
 
    /**
     * 訂單隊列與訂單交換機進行綁定
     * @return
     */
    @Bean
    public Binding bindOrder() {
        return BindingBuilder.bind(getOrderQueue()).to(getOrderExchange()).with(ORDER_ROUTING_KEY).noargs();
    }
 
}
View Code

 2.RedisCacheConfig.java

package com.example.demo.config;
 
 
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
 
/**
 * @ClassName: RedisCacheConfig
 * @Description: redis 緩存配置;
 * 注意:RedisCacheConfig這里也可以不用繼承:CachingConfigurerSupport,
 * 也就是直接一個普通的Class就好了 這里主要我們之后要重新實現
 * key的生成策略,只要這里修改KeyGenerator,其它位置不用修改就生效了。
 * 普通使用普通類的方式的話,那么在使用@Cacheable的時候還需要指定KeyGenerator的名稱;
 * 這樣編碼的時候比較麻煩。
 * @author: lst
 * @date: 2019年12月25日 下午3:30:19
 */
@Configuration
@EnableCaching // 啟用緩存,這個注解很重要;
public class RedisCacheConfig {
 
    @Autowired
    private RedisConnectionFactory redisConnectionFactory;
 
    /**
     * 緩存配置初始化一個cacheManager
     * @param connectionFactory
     * @return
     */
    @Bean
    public CacheManager cacheManager(RedisConnectionFactory connectionFactory) {
        RedisCacheManager redisCacheManager = RedisCacheManager.builder(connectionFactory).build();
        return redisCacheManager;
    }
 
 
    /**
     * 防止redis入庫序列化亂碼的問題
     * @param redisConnectionFactory
     * @return RedisTemplate
     */
    @Bean
    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(redisConnectionFactory);
 
        // 使用Jackson2JsonRedisSerialize 替換默認序列化
        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
 
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
        objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
        jackson2JsonRedisSerializer.setObjectMapper(objectMapper);
 
        // 設置value的序列化規則和 key的序列化規則
        redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
        redisTemplate.setHashValueSerializer(new StringRedisSerializer());
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        redisTemplate.afterPropertiesSet();
        return redisTemplate;
    }
 
    /**
     * 重寫hashOperations
     * @param redisTemplate
     * @return
     */
    @Bean
    public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
        return redisTemplate.opsForHash();
    }
 
    /**
     * 重寫listOperations
     * @param redisTemplate
     * @return
     */
    @Bean
    public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
        return redisTemplate.opsForList();
    }
 
    /**
     * redisMessageListenerContainer
     * @return
     */
    @Bean
    public RedisMessageListenerContainer redisMessageListenerContainer() {
        RedisMessageListenerContainer redisMessageListenerContainer = new RedisMessageListenerContainer();
        redisMessageListenerContainer.setConnectionFactory(redisConnectionFactory);
        return redisMessageListenerContainer;
    }
}
View Code

3.RedisUtil.java部分代碼

    /**
     * 對指定key的鍵值減一
     * @param key 鍵
     * @return Long
     */
    public Long decrBy(String key) {
        return redisTemplate.opsForValue().decrement(key);
    }
View Code

7.controller提供了二個方法,一個為redis+rabbitmq實現高並發秒殺,第二個則用純數據庫模擬秒殺,出現超賣現象。

package com.example.demo.controller;
 
import com.example.demo.result.RestResponse;
import com.example.demo.result.ResultGenerator;
import com.example.demo.service.StockService;
import com.example.demo.service.impl.MQStockServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * @author LST
 * @version 1.0
 * @Description: 秒殺
 * @date 2019-12-28 20:59
 */
@RestController
@Api(value = "SecKillController",  tags = "秒殺控制層")
@Slf4j
public class SecKillController {
 
 
    @Autowired
    private MQStockServiceImpl mQStockService;
 
    @Autowired
    private StockService stockService;
 
 
    /**
     * 使用redis+消息隊列進行秒殺實現
     * @param userName 用戶名稱
     * @param stockName 商品名稱
     * @return String
     */
    @PostMapping(value = "sec-kill",produces = "application/json")
    @ApiOperation(value = "redis+消息隊列進行秒殺實現", notes = "redis+消息隊列進行秒殺實現", produces = "application/json")
    public RestResponse secKill(@RequestParam(value = "userName") String userName, @RequestParam(value = "stockName") String stockName) {
        return ResultGenerator.genSuccessResult(mQStockService.secKill(userName, stockName));
    }
 
    /**
     * 實現純數據庫操作實現秒殺操作
     * @param userName 用戶名稱
     * @param stockName 商品名稱
     * @return String
     */
    @PostMapping(value = "sec-data-base",produces = "application/json;")
    @ApiOperation(value = "實現純數據庫操作實現秒殺操作", notes = "實現純數據庫操作實現秒殺操作", produces = "application/json")
    public RestResponse secDataBase(@RequestParam(value = "userName") String userName, @RequestParam(value = "stockName") String stockName) {
        return ResultGenerator.genSuccessResult(stockService.secDataBase(userName, stockName));
    }
 
 
}
View Code

8.需要在springboot得啟動類中進行對redis得初始化,簡而言之就是調用我們上面寫得方法,新建一個redis緩存,模擬商品信息。

package com.example.demo;
 
 
import com.example.demo.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
 
 
@SpringBootApplication
public class DemoApplication implements ApplicationRunner {
 
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
        /*SpringApplication springApplication = new SpringApplication(DemoApplication.class);
        ConfigurableApplicationContext configurableApplicationContext = springApplication.run(args);
        //解決WebSocket不能注入的問題  第一種方法
        WebSocketServerController.setApplicationContext(configurableApplicationContext);*/
    }
 
    @Autowired
    private RedisUtil redisUtil;
 
    /**
     * redis初始化商品的庫存量和信息
     * @param args
     * @throws Exception
     */
    @Override
    public void run(ApplicationArguments args) throws Exception {
        redisUtil.setValue("watch", 10, (long)20000);
    }
 
}
View Code

項目結構圖

6.redis+RabbitMQ測試

  1.項目啟動時,redis里的watch會初始化10。

 2.打開我們得JMeter工具運行測試(具體使用Jmeter可自行百度)

      1)選擇中文

       

   2)完成中文之后,我們在測試計划右鍵,添加一個線程組。

       

  3)給這個線程組的數量為40,這個線程組的作用就是模擬40個用戶發送請求,去秒殺;然后再在線程組右鍵,添加一個Http請求,這個就是我們用來發送請求的組件了

  

4)這個請求唯一要說得就是,隨機參數了,因為用戶名肯定不可能給40個相同得名字,這邊我們利用JMeter給用戶名得值為隨機數
點擊上方得白色小書本,選擇random,1-99得隨機數。

5)然后我們把這個函數字符串復制到http得參數上面去。

最后點擊運行按鈕運行。

5)查看控制台日志,可以看到運行結果已經打印到控制台了,用戶名為我們生成的隨機數。

再來看下數據庫訂單表t_order,就保存了10條數據(秒殺成功的),我們初始化的時候給watch庫存得數量為10,而我們使用JMeter模擬了40個人發請求,所以這10條數據,也就是40個用戶中搶到商品的10個人,也就是線程,誰搶到就是誰得。

6)再來查看下我們得結果樹

7.上面我們實現了redis+rabbitmq得秒殺,現在我們看看純數據庫方式得秒殺,看看有什么區別:

   1)首先網stock庫存表新增一條數據,類似於redis得初始化

   

  2)在jmeter中修改原來得http請求信息,其中華為對應數據庫得商品名,url改成sec-data-base,清空一下結果樹,我們開始運行。

3)查看控制台日志

16:03:42.335 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:95,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d2c25bc] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
16:03:42.358 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:63,秒殺的商品是:華為
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 10, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74ecd93] was not registered for synchronization because synchronization is not active
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d2c25bc]
16:03:42.366 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:95參加秒殺,當前商品庫存量是:10
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48a2eba7] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 10, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74ecd93]
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
16:03:42.369 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:63參加秒殺,當前商品庫存量是:10
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5fc6632f] was not registered for synchronization because synchronization is not active
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 10, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@48a2eba7]
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4763113f] was not registered for synchronization because synchronization is not active
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 10, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5fc6632f]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@be32227] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 9(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4763113f]
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@476ae572] was not registered for synchronization because synchronization is not active
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 9(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
16:03:42.387 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:12,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6ae2e6ea] was not registered for synchronization because synchronization is not active
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@be32227]
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3bf084e8] was not registered for synchronization because synchronization is not active
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: 2017963def0047039a5ba5651271e83f(String), 華為(String), 95(String), 95(String), 2019-12-30 16:03:42.384(Timestamp), 95(String), 2019-12-30 16:03:42.384(Timestamp), 0(String)
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@476ae572]
16:03:42.395 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:95.參加秒殺結果是:成功
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: e5f250658400411ba80ae850576d929e(String), 華為(String), 63(String), 63(String), 2019-12-30 16:03:42.39(Timestamp), 63(String), 2019-12-30 16:03:42.39(Timestamp), 0(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3bf084e8]
16:03:42.404 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:63.參加秒殺結果是:成功
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 9, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6ae2e6ea]
16:03:42.421 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:12參加秒殺,當前商品庫存量是:9
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5e7fd9d6] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
16:03:42.435 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:4,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4712e970] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
16:03:42.436 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:93,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@10188b2f] was not registered for synchronization because synchronization is not active
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 9, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4712e970]
16:03:42.440 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:4參加秒殺,當前商品庫存量是:9
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@35457672] was not registered for synchronization because synchronization is not active
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 9, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
<==      Total: 1
==> Parameters: 華為(String)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5e7fd9d6]
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@49f1bd9d] was not registered for synchronization because synchronization is not active
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 9, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 9, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@35457672]
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@10188b2f]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@470a3748] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
16:03:42.447 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:93參加秒殺,當前商品庫存量是:9
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@88082a2] was not registered for synchronization because synchronization is not active
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 8(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 8(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
16:03:42.457 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:60,秒殺的商品是:華為
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@591b3778] will not be managed by Spring
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e94a07f] was not registered for synchronization because synchronization is not active
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@470a3748]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@181fa237] was not registered for synchronization because synchronization is not active
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@49f1bd9d]
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@10b69781] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: c3c1359c372a4effbf18e89545bd1924(String), 華為(String), 4(String), 4(String), 2019-12-30 16:03:42.461(Timestamp), 4(String), 2019-12-30 16:03:42.461(Timestamp), 0(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@181fa237]
16:03:42.467 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:4.參加秒殺結果是:成功
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
==> Parameters: e361068837b145fb92fbe4627483e7cd(String), 華為(String), 12(String), 12(String), 2019-12-30 16:03:42.462(Timestamp), 12(String), 2019-12-30 16:03:42.462(Timestamp), 0(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 8, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 8, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@88082a2]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@63bb9313] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@591b3778] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 7(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e94a07f]
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@10b69781]
16:03:42.481 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:60參加秒殺,當前商品庫存量是:8
16:03:42.481 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:12.參加秒殺結果是:成功
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@63bb9313]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6fa28854] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@591b3778] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
Creating a new SqlSession
==> Parameters: 129bde847afb4e459430e7186565b9ce(String), 華為(String), 93(String), 93(String), 2019-12-30 16:03:42.481(Timestamp), 93(String), 2019-12-30 16:03:42.481(Timestamp), 0(String)
16:03:42.485 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:14,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@54efcd5f] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1beae077] was not registered for synchronization because synchronization is not active
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6fa28854]
16:03:42.487 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:93.參加秒殺結果是:成功
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 7, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@54efcd5f]
16:03:42.488 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:14參加秒殺,當前商品庫存量是:7
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b2af435] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 7, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 7, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b2af435]
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1beae077]
Creating a new SqlSession
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2b81e2b6] was not registered for synchronization because synchronization is not active
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@552bd5c4] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 6(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
==> Parameters: 華為(String), 6(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@552bd5c4]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c365627] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: 89de882982d94e3bb178407df18bb6ef(String), 華為(String), 14(String), 14(String), 2019-12-30 16:03:42.499(Timestamp), 14(String), 2019-12-30 16:03:42.499(Timestamp), 0(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c365627]
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2b81e2b6]
Creating a new SqlSession
16:03:42.505 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:14.參加秒殺結果是:成功
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7ba2da44] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: 529afce4171844e4ac441d725e4ac1d7(String), 華為(String), 60(String), 60(String), 2019-12-30 16:03:42.506(Timestamp), 60(String), 2019-12-30 16:03:42.506(Timestamp), 0(String)
16:03:42.509 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:45,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@75a72caa] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@67ea7108] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 6, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@75a72caa]
16:03:42.518 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:45參加秒殺,當前商品庫存量是:6
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6afd1f0] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@67ea7108] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 6, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6afd1f0]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74667454] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@67ea7108] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 5(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
16:03:42.531 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:83,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@677b1a0] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 5, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@677b1a0]
16:03:42.535 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:83參加秒殺,當前商品庫存量是:5
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f5997e2] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 5, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f5997e2]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3173d463] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
<==    Updates: 1
==> Parameters: 華為(String), 4(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7ba2da44]
16:03:42.540 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:60.參加秒殺結果是:成功
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@74667454]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1b796bdf] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@67ea7108] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: 70a08714a9ff491dab6494955aa385e4(String), 華為(String), 45(String), 45(String), 2019-12-30 16:03:42.547(Timestamp), 45(String), 2019-12-30 16:03:42.547(Timestamp), 0(String)
16:03:42.556 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:79,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@27e8bba7] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 4, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@27e8bba7]
16:03:42.559 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:79參加秒殺,當前商品庫存量是:4
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5df4ce35] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 4, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5df4ce35]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7cf51a8c] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 3(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
16:03:42.576 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:20,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f02d22f] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@591b3778] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 3, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1b796bdf]
<==      Total: 1
16:03:42.581 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:45.參加秒殺結果是:成功
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f02d22f]
16:03:42.582 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:20參加秒殺,當前商品庫存量是:3
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@62afdf25] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@591b3778] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7cf51a8c]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3d4d25c9] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@35fa3e98] will not be managed by Spring
==> Parameters: 華為(String)
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: 494eb80b41774b8fbbc4dae22d311f52(String), 華為(String), 79(String), 79(String), 2019-12-30 16:03:42.584(Timestamp), 79(String), 2019-12-30 16:03:42.584(Timestamp), 0(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 3, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@62afdf25]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@60de21af] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@591b3778] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 2(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3d4d25c9]
16:03:42.588 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:79.參加秒殺結果是:成功
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@60de21af]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@224bde9b] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@591b3778] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: 9a8e22d40130436da1b3c1b60a715cf7(String), 華為(String), 20(String), 20(String), 2019-12-30 16:03:42.592(Timestamp), 20(String), 2019-12-30 16:03:42.592(Timestamp), 0(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3173d463]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@32f00df0] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@224bde9b]
16:03:42.597 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:20.參加秒殺結果是:成功
==> Parameters: a1de640856ea4f0b8a351773ed1ef5dd(String), 華為(String), 83(String), 83(String), 2019-12-30 16:03:42.596(Timestamp), 83(String), 2019-12-30 16:03:42.596(Timestamp), 0(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@32f00df0]
16:03:42.603 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:83.參加秒殺結果是:成功
16:03:42.608 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:30,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@11356acb] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 2, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@11356acb]
16:03:42.612 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:30參加秒殺,當前商品庫存量是:2
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@20979825] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 2, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@20979825]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2863cde4] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 1(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2863cde4]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@63eba6b2] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: 1db6e42cef474c16a685855f9e30214a(String), 華為(String), 30(String), 30(String), 2019-12-30 16:03:42.629(Timestamp), 30(String), 2019-12-30 16:03:42.629(Timestamp), 0(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@63eba6b2]
16:03:42.633 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:30.參加秒殺結果是:成功
16:03:42.637 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:76,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7f215c5a] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 1, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7f215c5a]
16:03:42.641 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:76參加秒殺,當前商品庫存量是:1
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@f95a316] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 1, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@f95a316]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@44431388] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: UPDATE stock SET name=?, stock=?, remarks=?, create_by=?, create_date=?, update_by=?, update_date=? WHERE id=? AND del_flag='0' 
==> Parameters: 華為(String), 0(String), (String), 1(String), 2019-12-30 15:59:57.0(Timestamp), 1(String), 2019-12-30 15:59:55.0(Timestamp), 072a1824e30f45e79a904a2788961543(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@44431388]
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@786983f] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: INSERT INTO t_order ( id, order_name, order_user, create_by, create_date, update_by, update_date, del_flag ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? ) 
==> Parameters: f534c0d5613f4eed87fef8ef15fcd443(String), 華為(String), 76(String), 76(String), 2019-12-30 16:03:42.652(Timestamp), 76(String), 2019-12-30 16:03:42.652(Timestamp), 0(String)
<==    Updates: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@786983f]
16:03:42.656 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:76.參加秒殺結果是:成功
16:03:42.655 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:41,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7612fab8] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7612fab8]
16:03:42.663 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:41參加秒殺,當前商品庫存量是:0
16:03:42.663 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:41.參加秒殺結果是:秒殺已經結束
16:03:42.680 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:49,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e016b00] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3e016b00]
16:03:42.685 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:49參加秒殺,當前商品庫存量是:0
16:03:42.685 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:49.參加秒殺結果是:秒殺已經結束
16:03:42.703 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:73,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3dbe37d9] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3dbe37d9]
16:03:42.707 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:73參加秒殺,當前商品庫存量是:0
16:03:42.707 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:73.參加秒殺結果是:秒殺已經結束
16:03:42.733 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:42,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3707641f] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3707641f]
16:03:42.737 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:42參加秒殺,當前商品庫存量是:0
16:03:42.737 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:42.參加秒殺結果是:秒殺已經結束
16:03:42.769 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:2,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@25a916ca] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@25a916ca]
16:03:42.773 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:2參加秒殺,當前商品庫存量是:0
16:03:42.773 logback [http-nio-8090-exec-31] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:2.參加秒殺結果是:秒殺已經結束
16:03:42.792 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:80,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@46b3c133] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@46b3c133]
16:03:42.796 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:80參加秒殺,當前商品庫存量是:0
16:03:42.797 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:80.參加秒殺結果是:秒殺已經結束
16:03:42.817 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:63,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@129bff71] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@129bff71]
16:03:42.821 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:63參加秒殺,當前商品庫存量是:0
16:03:42.821 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:63.參加秒殺結果是:秒殺已經結束
16:03:42.842 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:3,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@161661ab] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@161661ab]
16:03:42.846 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:3參加秒殺,當前商品庫存量是:0
16:03:42.847 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:3.參加秒殺結果是:秒殺已經結束
16:03:42.866 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:67,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d238351] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d238351]
16:03:42.869 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:67參加秒殺,當前商品庫存量是:0
16:03:42.869 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:67.參加秒殺結果是:秒殺已經結束
16:03:42.895 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:68,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@38d140da] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@38d140da]
16:03:42.909 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:68參加秒殺,當前商品庫存量是:0
16:03:42.909 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:68.參加秒殺結果是:秒殺已經結束
16:03:42.921 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:57,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4d8d3a17] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4d8d3a17]
16:03:42.924 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:57參加秒殺,當前商品庫存量是:0
16:03:42.924 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:57.參加秒殺結果是:秒殺已經結束
16:03:42.941 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:96,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@19940d0c] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@19940d0c]
16:03:42.943 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:96參加秒殺,當前商品庫存量是:0
16:03:42.944 logback [http-nio-8090-exec-29] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:96.參加秒殺結果是:秒殺已經結束
16:03:42.965 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:48,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4a8a0c04] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4a8a0c04]
16:03:42.968 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:48參加秒殺,當前商品庫存量是:0
16:03:42.968 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:48.參加秒殺結果是:秒殺已經結束
16:03:42.990 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:95,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5fb9f5d5] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5fb9f5d5]
16:03:42.992 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:95參加秒殺,當前商品庫存量是:0
16:03:42.993 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:95.參加秒殺結果是:秒殺已經結束
16:03:43.015 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:63,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53f117b5] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@53f117b5]
16:03:43.018 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:63參加秒殺,當前商品庫存量是:0
16:03:43.019 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:63.參加秒殺結果是:秒殺已經結束
16:03:43.042 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:31,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4a3fd371] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4a3fd371]
16:03:43.047 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:31參加秒殺,當前商品庫存量是:0
16:03:43.047 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:31.參加秒殺結果是:秒殺已經結束
16:03:43.065 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:22,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f395b40] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6f395b40]
16:03:43.067 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:22參加秒殺,當前商品庫存量是:0
16:03:43.067 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:22.參加秒殺結果是:秒殺已經結束
16:03:43.096 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:97,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@29ffdd03] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@29ffdd03]
16:03:43.104 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:97參加秒殺,當前商品庫存量是:0
16:03:43.105 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:97.參加秒殺結果是:秒殺已經結束
16:03:43.126 logback [http-nio-8090-exec-2] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:85,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@475a6109] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@475a6109]
16:03:43.131 logback [http-nio-8090-exec-2] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:85參加秒殺,當前商品庫存量是:0
16:03:43.132 logback [http-nio-8090-exec-2] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:85.參加秒殺結果是:秒殺已經結束
16:03:43.142 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:95,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4fe59aed] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@4fe59aed]
16:03:43.145 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:95參加秒殺,當前商品庫存量是:0
16:03:43.146 logback [http-nio-8090-exec-13] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:95.參加秒殺結果是:秒殺已經結束
16:03:43.164 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:34,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2b09efef] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2b09efef]
16:03:43.166 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:34參加秒殺,當前商品庫存量是:0
16:03:43.166 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:34.參加秒殺結果是:秒殺已經結束
16:03:43.188 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:77,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2337f6dd] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2337f6dd]
16:03:43.191 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:77參加秒殺,當前商品庫存量是:0
16:03:43.191 logback [http-nio-8090-exec-17] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:77.參加秒殺結果是:秒殺已經結束
16:03:43.224 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:99,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@182e9ec3] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@182e9ec3]
16:03:43.235 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:99參加秒殺,當前商品庫存量是:0
16:03:43.238 logback [http-nio-8090-exec-28] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:99.參加秒殺結果是:秒殺已經結束
16:03:43.242 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:27,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@365502d7] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@365502d7]
16:03:43.249 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:27參加秒殺,當前商品庫存量是:0
16:03:43.249 logback [http-nio-8090-exec-38] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:27.參加秒殺結果是:秒殺已經結束
16:03:43.265 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:37,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5a2e99b6] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5a2e99b6]
16:03:43.267 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:37參加秒殺,當前商品庫存量是:0
16:03:43.268 logback [http-nio-8090-exec-19] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:37.參加秒殺結果是:秒殺已經結束
16:03:43.300 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:22,秒殺的商品是:華為
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16d8ccb7] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
16:03:43.316 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 參加秒殺的用戶是:91,秒殺的商品是:華為
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@9c2e762] was not registered for synchronization because synchronization is not active
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16d8ccb7]
16:03:43.317 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:22參加秒殺,當前商品庫存量是:0
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@165324af] will not be managed by Spring
16:03:43.318 logback [http-nio-8090-exec-40] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:22.參加秒殺結果是:秒殺已經結束
==>  Preparing: SELECT id,name,stock,remarks,create_by AS createBy,create_date AS createDate,update_by AS updateBy,update_date AS updateDate,del_flag AS delFlag FROM stock WHERE del_flag='0' AND name = ? 
==> Parameters: 華為(String)
<==    Columns: id, name, stock, remarks, createBy, createDate, updateBy, updateDate, delFlag
<==        Row: 072a1824e30f45e79a904a2788961543, 華為, 0, , 1, 2019-12-30 15:59:57, 1, 2019-12-30 15:59:55, 0
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@9c2e762]
16:03:43.324 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:91參加秒殺,當前商品庫存量是:0
16:03:43.324 logback [http-nio-8090-exec-33] INFO  c.e.d.service.impl.StockServiceImpl - 用戶:91.參加秒殺結果是:秒殺已經結束
View Code

4)查看t_order和stock表

         stock表的華為商品庫存已經清空。

   再看看t_order 表有13條記錄,這樣我們可以看到,明明只有10個庫存得商品,搶到得人卻不止10個,這樣明細超賣了,請求樹也可以看的超賣信息。

需要源碼的伙伴可前往自行下載,附上下載地址:https://download.csdn.net/download/qq_33612228/12065894


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM