开启的服务:redis、zookeeper
运行顺序:先打开redis和zookeeper、服务提供者、服务消费者
一、接口工程
添加的依赖:无
主配置文件:无
二、服务提供者
添加的依赖:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--springboot框架项目父工程-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/>
</parent>
<!--该项目的gav-->
<groupId>com.springboot</groupId>
<artifactId>15-springboot-dubbo-ssm-provider</artifactId>
<version>1.0.0</version>
<!--该项目依赖的jdk版-->
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--springboot框架web项目起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--接口工程依赖-->
<dependency>
<groupId>com.springboot</groupId>
<artifactId>15-springboot-dubbo-ssm-interface</artifactId>
<version>1.0.0</version>
</dependency>
<!--mysql依赖-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.20</version>
</dependency>
<!--mybatis整合springboot-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<!--springboot整合redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!--dubbo整合springboot框架-->
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<!--zookeeper依赖-->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--springboot框架项目编译、打包插件-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!--mybatis逆向工程打包插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
<configurationFile>
src/main/resources/GeneratorMapper.xml
</configurationFile>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>
</project>
主配置文件
#配置tomcat启动端口
server.port=8088
#配置上下文根
server.servlet.context-path=/
#配置mysql四要素
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test
spring.datasource.username=duchao
spring.datasource.password=123456
#配置redis三要素
spring.redis.host=127.0.0.1
spring.redis.port=6379
#spring.redis.password=123456
#配置dubbo
spring.application.name=15-springboot-dubbo-ssm-provider
spring.dubbo.server=true
spring.dubbo.registry=zookeeper://localhost:2181
三、服务消费者
添加的依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--springboot项目的父工程-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/>
</parent>
<!--该项目的gav-->
<groupId>com.springboot</groupId>
<artifactId>15-springboot-dubbo-ssm-consumer</artifactId>
<version>1.0.0</version>
<!--该项目依赖的jdk版本-->
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--springboot框架web项目起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--解析jsp文件-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!--dubbo集成springboot-->
<dependency>
<groupId>com.alibaba.spring.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<!--springboot集成zookeeper-->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.10</version>
</dependency>
<!--接口项目依赖-->
<dependency>
<groupId>com.springboot</groupId>
<artifactId>15-springboot-dubbo-ssm-interface</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--springboot框架项目编译、打包插件-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/webapp</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>*.jsp</include>
</includes>
</resource>
</resources>
</build>
</project>
主配置文件
#配置tomcat启动端口号
server.port=8089
#配置上下文根
server.servlet.context-path=/
#配置dubbo
spring.application.name=15-springboot-dubbo-ssm-consumer
spring.dubbo.registry=zookeeper://localhost:2181