This article introduces the project creation and environment construction of Springboot's integrated Dubbo tutorial. It is shared with you. The details are as follows:
1. Create a new Maven project using IDEA
Create a new project
After selecting Maven, click next
Select a project type
Configure the Maven coordinates of the project
Set the project name and save location
Modify the project's pom.xml file
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.boot</groupId> <artifactId>boot-dubbo</artifactId> <version>1.0-SNAPSHOT</version> <!--The package type is set to pom here, and the purpose is to implement multi-module projects--> <packaging>pom</packaging></project>
2. Create a boot-dubbo submodule project
Create a Dubbo service interface project. We build the project under the boot-dubbo project we created just now and manage it as a submodule project of boot-dubbo.
Click on the newly created project we just built and create a new boot-dubbo submodule project
Submodule project of a new project
Click next after selecting Maven
Configure module parameters
Complete the creation of project submodules
Similarly, we continue our second step and create two submodule projects: boot-dubbo-provider and boot-dubbo-consumer.
After creation, our overall project structure diagram is shown in the following figure:
Project completion structure diagram
At this point, our preparations for creating the project have been completed.
3. Define the pom.xml file for each project
Open the pom.xml file of our top-level project boot-dubbo
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.boot</groupId> <artifactId>boot-dubbo</artifactId> <version>1.0-SNAPSHOT</version> <!-- Here is the settings of our submodule --> <modules> <module>boot-dubbo-api</module> <module>boot-dubbo-provider</module> <module>boot-dubbo-consumer</module> </modules> <!-- Set the packaging type to pom here, which is to implement multi-module projects --> <packaging>pom</packaging> <!-- Step 1: Add Springboot's parent --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.7.RELEASE</version> </parent> <!-- Set some version properties of our project --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.8</java.version> <dubbo.version>2.5.5</dubbo.version> <zkclient.version>0.10</zkclient.version> <lombok.version>1.16.18</lombok.version> <spring-boot.version>1.5.7.RELEASE</spring-boot.version> </properties> <!-- Declare some project dependency management to facilitate our dependency version management --> <dependencyManagement> <dependencies> <!-- Springboot dependency--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>${spring-boot.version}</version> </dependency> <!-- Springboot-web dependency--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>${spring-boot.version}</version> </dependency> <!-- Use lombok to implement automatic generation of JavaBean's get, set, toString, hashCode, equals and other methods--> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> <scope>provided</scope> </dependency> <!-- Dubbo dependencies --> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>${dubbo.version}</version> </dependency> <!-- client dependencies of zookeeper --> <dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</artifactId> <version>${zkclient.version}</version> </dependency> </dependencies> </dependencyManagement></project>boot-dubbo-api pom.xml file
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>boot-dubbo</artifactId> <groupId>com.boot</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>boot-dubbo-api</artifactId> <dependencies> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> </dependencies></project>
pom.xml file of boot-dubbo-provider
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>boot-dubbo</artifactId> <groupId>com.boot</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>boot-dubbo-provider</artifactId> <dependencies> <dependency> <groupId>com.boot</groupId> <artifactId>boot-dubbo-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> </dependency> <dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</artifactId> </dependency> </dependency> </dependency> </build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugins> </build></project>
pom.xml file of boot-dubbo-consumer
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <artifactId>boot-dubbo</artifactId> <groupId>com.boot</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>boot-dubbo-consumer</artifactId> <dependencies> <dependency> <groupId>com.boot</groupId> <artifactId>boot-dubbo-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> </dependency> <dependency> <groupId>com.101tec</groupId> <artifactId>zkclient</artifactId> </dependency> </dependency> </build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build></project>
Project address: springboot-dubbo project GitHub address https://github.com/zhangxieliu/springboot-dubbo
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.