Coder Social home page Coder Social logo

springboot-mall's Introduction

springboot-mall

##使用springboot实现网上商城

系统架构 Image text

开发环境

依赖 版本 Window Linux
JDK 8
Tomcat 8
Mysql 5
IDEA 2018
Zookeeper
FastDFS
Nginx
ES 6
kibana 6

各个模块端口

模块 端口
user 8090
mall-admin 8888
manage-web 8080
manage-service 8070
user-web 8081
user-service 8071
item-web 8082
search-web 8083
search-service 8073
cart-web 8084
cart-service 8074
passport-web 8085
order-service 8076
order-web 8086

各个子模块说明

  • generator:逆向工程
  • mall-parent:管理所有依赖的版本
  • mall-api:存放pojo类和service接口
  • mall-common-utils:通用jar
  • mall-web-util:Web、Controller层通用jar
  • mall-service-util:Service层通用jar

遇到的问题及注意事项:
Tip 1:

  1. 因为使用的是SpringBoot 2的版本,使用数据库驱动时会报service zone错误,
    在核心配置文件spring.datasource.url属性添加?serverTimezone=GMT解决
    因为mysql8.0版本要求更加细化
  2. 因为使用了tk.mybatis的通用Mapper,MBG理论上不用生成Mapper接口和xml文件
    启动类的@MapperScan要使用tk.mybatis的,我们的Mapper接口要继承tk的Mapper类
  3. 使用idea+mvaen+java代码逆向工程生成文件时,路径要使用绝对路径。原因未解决

Tip 2:

  1. 所有pojo类要实现Serializable接口,因为使用dubbo,所以pojo是在网络上进行传输的
  2. 网络传输依赖注入要使用Dubbo的@Reference,而不是@Autowired
  3. 服务层@Service也要换成Dubbo
  4. linux配置各个文件时,要注意路径

Tip 3:

  1. 今天启动项目怎么也连不上ZooKeeper,报 ERROR zkclient.ZkClientWrapper: [DUBBO] Timeout! zookeeper server can not be connected in : 30000ms!, dubbo version: 2.0.0, current host: 127.0.0.1 原因:因为我一次性启动了多个项目,导致连接时间过长
    解决:1. 项目一个个启动
    2. 设置Zookeeper连接超时时间,spring.dubbo.registry.timeout
  2. 由于前后端分离,后端Controller要加@CrossOrigin
  3. 增删改都在一个ServiceImpl的同一个方法里处理,非常有意思
    方法位置com.gdou.mall.manage.service.impl.AttrServiceImpl.saveAttrInfo

Tip 4:

  1. 使用了@JSONField绑定不上数据; 原因:SpringBoot默认使用jackSon
    解决办法
  2. Linux部署FastDFS时,没有storage服务
    原因:tracker_server=127.0.0.1:22122,虽然tracker和storage都在同一台虚拟机上,但是不能用127.0.0.1
    解决:tracker_server=trackerIP:22122

Tip 5:

  1. Controller上传图片到FastDFS过程中连不上Storage服务
    原因:Linux没开放23000端口
    解决:iptables开放23000端口,ps:Tracker Server端口22122
  2. 访问图片时不能显示图片,<img src="192.168.141.128/group1/M00/00/00/wKiNgF6IhLOAG6y8AATrdYpbQmQ186.png">
    原因:src路径没加http//:,会被自动加上http//:localhost:8080/项目名
    解决:存储Img src时加上http//:

Tip 6:

  1. 今天的大坑,id为Long类型,id作为值存入Map<String,Object>,即Long类型转为Object,
    当从Map出来时,以String类型封装id,此时应该会报java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
    但是,SpringBoot却报NullPointException,而且不debug到具体语句,也不会报具体的异常点,导致异常非常难找
  2. mybatis in #{}只能修改第一个, 换成${}出现getter错误 @Param

Tip 7:

  1. 今天测试,发现拦截器只拦截某些Handler, 原因:SpringBoot启动类不与拦截器类在同一级目录或上级,导致该SpringBoot启动类加载不到该拦截器类

springboot-mall's People

Contributors

ration-h avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.