使用springboot怎么实现商场秒杀功能

使用springboot怎么实现商场秒杀功能?针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。

创新互联专业为企业提供綦江网站建设、綦江做网站、綦江网站设计、綦江网站制作等企业网站建设、网页设计与制作、綦江企业网站模板建站服务,十年綦江做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

加入主要依赖


 org.springframework.boot
 spring-boot-starter-thymeleaf



 com.alibaba
 druid
 1.0.5



 redis.clients
 jedis


 com.alibaba
 fastjson
 1.2.38


 commons-codec
 commons-codec


 org.springframework.boot
 spring-boot-starter-validation


 org.springframework.boot
 spring-boot-starter-amqp


 com.google.guava
 guava
 19.0

秒杀项目主要目录构架

1.java目录

config 所有的配置信息
controller
exception 所有业务异常
mapper
service
rabbitmq
redis redis缓存
validator 后端校验
bean:数据传输层包括:MySQL以及redis
util:工具包
dto:数据传输对象

秒杀系统逻辑

使用springboot怎么实现商场秒杀功能

实现技术点

1.MD5

实现用户的密码为加密在保存到数据库之前

2.全局异常统一处理

通过拦截所有异常,对各种异常进行相应的处理

3.页面缓存

通过手动渲染的html页面缓存到redis中

WebContext ctx = new WebContext(request, response, request.getServletContext(), request.getLocale(), model.asMap());
html = thymeleafViewResolver.getTemplateEngine().process("goods_detail", ctx);

4.解决了超买

application.properties配置
#thymeleaf
spring.thymeleaf.cache=false
spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.enabled=true
spring.thymeleaf.encoding=utf-8
spring.thymeleaf.mode=HTML5
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
# mybatis
mybatis.type-aliases-package=com.jesper.seckill.mapper
mybatis.configuration.map-underscore-to-camel-case=true
mybatis.configuration.default-fetch-size=100
mybatis.configuration.default-statement-timeout=3000
mybatis.mapperLocations = classpath:com/jesper/seckill/mapper/*.xml
# druid
spring.datasource.url=jdbc:mysql://localhost:3306/seckill?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.filters=stat
spring.datasource.maxActive=1000
spring.datasource.initialSize=100
spring.datasource.maxWait=60000
spring.datasource.minIdle=500
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000
spring.datasource.validationQuery=select 'x'
spring.datasource.testWhileIdle=true
spring.datasource.testOnBorrow=false
spring.datasource.testOnReturn=false
spring.datasource.poolPreparedStatements=true
spring.datasource.maxOpenPreparedStatements=20
#redis
redis.host=127.0.0.1
redis.port=6379
redis.timeout=10
redis.poolMaxTotal=1000
redis.poolMaxIdle=500
redis.poolMaxWait=500
#static
spring.resources.add-mappings=true
spring.resources.cache.period= 3600
spring.resources.chain.cache=true 
spring.resources.chain.enabled=true
spring.resources.chain.compressed=true
spring.resources.chain.html-application-cache=true
spring.resources.static-locations=classpath:/static/
#rabbitmq
spring.rabbitmq.host=127.0.0.1
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
spring.rabbitmq.virtual-host=/
spring.rabbitmq.listener.simple.concurrency= 10
spring.rabbitmq.listener.simple.max-concurrency= 10
spring.rabbitmq.listener.simple.prefetch= 1
spring.rabbitmq.listener.simple.auto-startup=true
spring.rabbitmq.listener.simple.default-requeue-rejected= true
spring.rabbitmq.template.retry.enabled=true
spring.rabbitmq.template.retry.initial-interval=1000
spring.rabbitmq.template.retry.max-attempts=3
spring.rabbitmq.template.retry.max-interval=10000
spring.rabbitmq.template.retry.multiplier=1.0

springboot是什么

springboot一种全新的编程规范,其设计目的是用来简化新Spring应用的初始搭建以及开发过程,SpringBoot也是一个服务于框架的框架,服务范围是简化配置文件。

关于使用springboot怎么实现商场秒杀功能问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。


本文题目:使用springboot怎么实现商场秒杀功能
新闻来源:http://bzwzjz.com/article/psdhdg.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站制作 成都h5网站建设 网站设计 高端网站设计 成都网站建设 品牌网站建设 成都网站建设 营销型网站建设 上市集团网站建设 成都品牌网站建设 达州网站设计 四川成都网站制作 手机网站制作 专业网站设计 高端品牌网站建设 成都定制网站建设 成都网站建设 企业网站建设 网站制作 网站设计公司 营销型网站建设 成都响应式网站建设