尚好房是一个二手房管理服务平台,开放优质资源和线上能力,聚合线上线下二手房产资源,打造一个全方位二手房服务生态市场,为消费者提供优质房产服务资源。
2、核心技术| 基础框架:ssm |
|---|
| 分布式框架:ssm + Dubbo + zk |
| spring session redis实现session共享 |
| 图片服务器:七牛云 |
| 后台管理权限控制:spring-security |
| 前端用户登录判断:拦截器 |
| 后台管理模板:Thymeleaf |
| 前端技术:Vue+Axios |
最终分布式架构模块
shf-parent:根目录,管理子模块:
common-util:公共类模块
model:实体类模块
service:dubbo服务父节点
service-acl:权限服务模块
service-house:房源服务模块
service-user:用户服务模块
service-api:dubbo服务api接口
web:前端(dubbo服务消费者)
web-admin:后台管理系统
web-front:网站前端
模块调用关系,如图:
4、项目演示地址尚好房后台管理系统:http://139.198.152.148:8001/
尚好房前端:http://139.198.152.148:8002/
根据演示了解项目业务
5、数据库数据库从资源文件中获取,导入数据库,数据库表如下:
6、其他资源如:实体类、工具类直接复制到项目模块使用,后续使用时再详细说明,其他资源需要时引入。
二、搭建环境目前我们先搭建“尚好房”后台管理系统,该系统为单体架构:SSM框架,后续我们通过SSM架构过渡到Dubbo通信的分布式架构。
SSM单体架构模块:
shf-parent:根目录,管理子模块:
common-util:公共类模块
model:实体类模块
web-admin:后台管理系统
搭建SSM架构我们分三步进行:
1、搭建项目结构
2、配置依赖关系
3、配置SSM环境
4、测试SSM环境
1、搭建项目结构 1.1、搭建父工程shf-parentshf:尚好房首字母缩写
第一步:新建项目
第二步:
第三步:
第四步:
项目结构如:
删除src目录
1.2、搭建工具类模块common-util第一步:右键点击“shf-parent”
第二步:
第三步:
第四步:
项目结构如:
引入“资料/java工具类”相关代码
1.3、搭建实体类模块model搭建方式如:common-util
项目结构如:
引入“资料/java实体类”相关代码
1.4、搭建项目模块web-admin第一步:右键点击“shf-parent”
第二步:
第三步:
第四步:
项目结构如:
说明:模块web-admin还缺少webapp/WEB-INF目录及web.xml文件
第一步:在pom.xml文件中指定打包方式为war
第二步:在main下直接创建webapp/WEB-INF/web.xml文件
2、配置依赖关系 2.1、shf-parent父模块管理依赖版本web
修改shf-parent模块pom.xml文件
2.2、common-util模块4.0.0 com.atguigu shf-parent pom 1.0 common-util model web-admin 1.8 5.2.7.RELEASE 3.0.11.RELEASE 4.1.4 2.5 1.2.29 3.4.5 1.3.1 8.0.18 1.1.12 1.3.1 1.7.30 1.2.3 org.springframework spring-webmvc ${spring.version} org.springframework spring-jdbc ${spring.version} org.springframework spring-tx ${spring.version} org.springframework spring-aspects ${spring.version} org.springframework spring-test ${spring.version} org.thymeleaf thymeleaf-spring5 ${thymeleaf.version} com.github.pagehelper pagehelper ${pagehelper.version} org.mybatis mybatis ${mybatis.version} org.mybatis mybatis-spring ${mybatis.spring.version} mysql mysql-connector-java ${mysql.version} com.alibaba druid ${druid.version} commons-fileupload commons-fileupload ${commons-fileupload.version} com.alibaba fastjson ${fastjson.version} org.slf4j slf4j-api ${slf4j-version} ch.qos.logback logback-classic ${logback-version} javax.servlet servlet-api ${servlet-api.version} provided org.apache.maven.plugins maven-compiler-plugin 3.2 1.8 1.8 UTF-8
common-util模块负责:依赖与常用工具类管理
2.3、web-admin模块shf-parent com.atguigu 1.0 4.0.0 common-util org.springframework spring-webmvc org.springframework spring-jdbc org.springframework spring-tx org.springframework spring-aspects org.springframework spring-test org.thymeleaf thymeleaf-spring5 com.github.pagehelper pagehelper org.mybatis mybatis org.mybatis mybatis-spring mysql mysql-connector-java com.alibaba druid commons-fileupload commons-fileupload com.alibaba fastjson org.slf4j slf4j-api ch.qos.logback logback-classic
web-admin模块依赖:common-util与model模块
shf-parent com.atguigu 1.0 4.0.0 web-admin war com.atguigu common-util 1.0 com.atguigu model 1.0 org.eclipse.jetty jetty-maven-plugin 9.4.15.v20190215 10 / 8000
说明:web容器我们使用jetty,与tomcat一样,jetty更轻量级。
3、配置SSM环境操作模块:web-admin
上面我们已经添加好项目依赖关系,接下来搭建ssm环境
ssm前端模板我们使用:thymeleaf模板
3.1、添加日志文件在resources目录添加:
logback.xml
3.2、SSM分层%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
ssm分为三层:
controller、service与dao层
我们为每一层分配添加一个配置文件,方便配置文件管理:
spring-mvc.xml
spring-service.xml
spring-dao.xml
3.3、添加dao层配置文件添加ibatis配置文件:
在resources目录添加:mybatis-config.xml
添加ibatis与spring集成的配置文件
在resources/spring目录添加:spring-dao.xml:
4.8、添加页面classpath:mapper @RequestMapping public String index(ModelMap model) { List list = roleService.findAll(); model.addAttribute("list", list); return PAGE_INDEX; } }
在WEB-INFE下创建模板总的文件夹:templates
在templates下创建角色文件夹:role
在role文件夹下创建文件:index.html
Title
| 11 | 22 | 33 | 33 | 33 |
第一步:
第二步:
4.10、访问测试 4.11、汇总public String index(ModelMap model) {
List list = roleService.findAll();
model.addAttribute("list", list);
return PAGE_INDEX;
}
}



