公共工程搭建和工具类导入
-
(1)公共子模块shop-common,pom.xml引入依赖
公共子模块引入这些依赖后,其他微服务引入shop-common后也自动引入了这些依赖
打包方式<packaging>jar</packaging>
-
(2)创建entity包 ,在entity包下创建返回状态码实体类
-
(3)包下建立类Result用于微服务返回结果给前端
-
(4)在entity包下建立类用于承载分页的数据结果PageResult
pom.xml
<parent>
<artifactId>shop-parent</artifactId>
<groupId>com.wzx</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- 1,当前工程是存储所有工程共有的东西-->
<!-- 2,其他工程将当前的jar添加进去-->
<packaging>jar</packaging>
<modelVersion>4.0.0</modelVersion>
<artifactId>shop-01common</artifactId>
<dependencies>
<!--web起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- redis 使用-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--eureka-client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!--openfeign-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!--微信支付-->
<dependency>
<groupId>com.github.wxpay</groupId>
<artifactId>wxpay-sdk</artifactId>
<version>0.0.3</version>
</dependency>
<!--httpclient支持-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
复制工具类
clean ,install
公共数据库工程搭建
- (1)创建公共模块shop-common-db ,pom文件引入依赖
这个公共模块是连接mysql数据库的公共微服务模块,所以需要连接mysql的微服务都继承自此工程。
pom.xml
<parent>
<artifactId>shop-parent</artifactId>
<groupId>com.wzx</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<!-- 1 设置当前工程打包为jar-->
<packaging>jar</packaging>
<artifactId>shop-02common-db</artifactId>
<!-- 2 设置数据库的mybatis-->
<!--依赖-->
<dependencies>
<!--对shop-common的依赖-->
<dependency>
<groupId>com.wzx</groupId>
<artifactId>shop-01common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!--通用mapper起步依赖-->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.0.4</version>
</dependency>
<!--MySQL数据库驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--mybatis分页插件-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>