2023-02-10
一、项目介绍
1、介绍
尚好房是一个二手房管理服务平台,开放优质资源和线上能力,聚合线上线下二手房产资源,打造一个全方位二手房服务生态市场,为消费者提供优质房产服务资源。
2、核心技术
(1)基础框架:ssm
(2)分布式框架:ssm + Dubbo + zk
(3)spring session redis 实现session共享
(4)图片服务器:七牛云
(5)后台管理权限控制:spring-security
(6)前端用户登陆判断:拦截器
(7)后台管理模块:Thymeleaf
(8)前端技术:Vue + Axios
3、项目模块
最终为分布式架构模块
(1)shf-parent:根目录,管理子模块:
①common-util:公共类模块
②model:实体类模块
③service:dubbo服务父节点
service-acl:权限服务模块
service-house:房源服务模块
service-user:用户服务模块
service-api:dubbo服务api接口
④web:前端(dubbo服务消费者)
web-admin:后台管理系统
web-front:网站前端
4、数据库
6、其他资源
实体类,工具类
二、环境搭建
1、创建idea项目,搭建父工程shf-parent
①打开idea,店家“create new project”,选择“maven”点击“next”。
点击“finish”
②删除“src”文件夹
③忽略.idea
2、搭建工具类common-util模块
①将鼠标停留在父工程的位置,右击“new module”,选择“maven”,点击“next”
点击“finish”
②在“shf-parent/common-util/src/main/java/com.hh”下创建两个文件夹“result”、“util”,将代码导入对应位置
3、搭建实体类模块model
①将鼠标停留在父工程的位置,右击“new module”,选择“maven”,点击“next”
点击“finish”
②在“shf-parent/model/src/main/java/com.hh”下创建两个文件夹“entity”、“vo”,将代码导入对应位置
4、搭建项目模块web-admin
同上
注意:
①web工程的打包方式是war包,需要在“shf-parent/web-admin/src/pom.xml”中的内部添加打包方式
<!-- web工程的打包方式是war--> <packaging>war</packaging>
②在main下直接创建webapp/WEB-INF/web.xml
放置web.xml的约束
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <display-name>web</display-name></web-app>
三、配置依赖关系
1、在“shf-parent/pom.xml”下的中导入依赖
<properties> <java.version>1.8</java.version> <spring.version>5.2.7.RELEASE</spring.version> <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version> <pagehelper.version>4.1.4</pagehelper.version> <servlet-api.version>2.5</servlet-api.version> <fastjson.version>1.2.29</fastjson.version> <mybatis.version>3.4.5</mybatis.version> <mybatis.spring.version>1.3.1</mybatis.spring.version> <mysql.version>8.0.18</mysql.version> <druid.version>1.1.12</druid.version> <commons-fileupload.version>1.3.1</commons-fileupload.version> <slf4j-version>1.7.30</slf4j-version> <logback-version>1.2.3</logback-version> </properties> <!-- 依赖管理 --> <dependencyManagement> <dependencies> <!-- SpringMVC相关 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <!--spring封装的jdbc数据库访问--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${spring.version}</version> </dependency> <!--Spring提供的对AspectJ框架的整合--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>${spring.version}</version> </dependency> <!--用于spring测试--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${spring.version}</version> </dependency> <!--用于springMVC模板--> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring5</artifactId> <version>${thymeleaf.version}</version> </dependency> <!--mybatis的分页插件--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>${pagehelper.version}</version> </dependency> <!-- Mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <!-- Mybatis与Spring整合所需要的jar包 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>${mybatis.spring.version}</version> </dependency> <!-- MySql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <!-- 连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <!-- 文件上传组件 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>${commons-fileupload.version}</version> </dependency> <!-- fastjson --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${fastjson.version}</version> </dependency> <!-- 日志 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j-version}</version> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback-version}</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>${servlet-api.version}</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <!-- java编译插件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.2</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build>
2、在“shf-parent/common-util/pom.xml”下的中导入依赖
<dependencies> <!-- SpringMVC相关 --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </dependency> <!--spring封装的jdbc数据库访问--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> </dependency> <!--Spring提供的对AspectJ框架的整合--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> </dependency> <!--用于spring测试--> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> </dependency> <!--用于springMVC模板--> <dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring5</artifactId> </dependency> <!--mybatis的分页插件--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> </dependency> <!-- Mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> </dependency> <!-- Mybatis与Spring整合所需要的jar包 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> </dependency> <!-- MySql --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <!-- 连接池 --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <!-- 文件上传组件 --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> </dependency> <!-- fastjson --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> </dependency> <!-- 日志 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> </dependency> </dependencies>
3、在“shf-parent/web-admin/pom.xml”下的中导入依赖
<dependencies> <dependency> <groupId>com.hh</groupId> <artifactId>common-util</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>com.hh</groupId> <artifactId>model</artifactId> <version>1.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> <version>9.4.15.v20190215</version> <configuration> <!-- 如果检测到项目有更改则自动热部署,每隔n秒扫描一次。默认为0,即不扫描--> <scanIntervalSeconds>10</scanIntervalSeconds> <webAppConfig> <!--指定web项目的根路径,默认为/ --> <contextPath>/</contextPath> </webAppConfig> <httpConnector> <!--端口号,默认 8080--> <port>8000</port> </httpConnector> </configuration> </plugin> </plugins> </build>