本章介绍SpringBoot与与Dubbo。

  Apache Dubbo 是一个基于Java的高性能,轻量级的RPC框架。Dubbo提供了三个关键功能,包括基于接口的远程呼叫,容错和负载平衡以及自动服务注册和发现。

  1、新建一个项目SpringBoot Web项目,引入Dubbo依赖

1 <!-- Dubbo Spring Boot Starter -->
2 <dependency>
3     <groupId>org.apache.dubbo</groupId>
4     <artifactId>dubbo-spring-boot-starter</artifactId>
5     <version>2.7.5</version>
6 </dependency>

    完整pom文件如下:

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0"
 3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 5     <modelVersion>4.0.0</modelVersion>
 6 
 7     <groupId>com.test</groupId>
 8     <artifactId>test-springboot-dubbo-provider</artifactId>
 9     <version>1.0-SNAPSHOT</version>
10 
11     <parent>
12         <groupId>org.springframework.boot</groupId>
13         <artifactId>spring-boot-starter-parent</artifactId>
14         <version>2.1.8.RELEASE</version>
15     </parent>
16 
17     <properties>
18         <dubbo.version>2.7.5</dubbo.version>
19         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20         <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
21         <java.version>1.8</java.version>
22     </properties>
23 
24     <dependencies>
25 
26         <dependency>
27             <groupId>org.springframework.boot</groupId>
28             <artifactId>spring-boot-starter-web</artifactId>
29         </dependency>
30 
31         <!-- Dubbo Spring Boot Starter -->
32         <dependency>
33             <groupId>org.apache.dubbo</groupId>
34             <artifactId>dubbo-spring-boot-starter</artifactId>
35             <version>${dubbo.version}</version>
36         </dependency>
37 
38         <dependency>
39             <groupId>org.springframework.boot</groupId>
40             <artifactId>spring-boot-starter-test</artifactId>
41             <scope>test</scope>
42         </dependency>
43 
44     </dependencies>
45 
46 
47     <!-- SpringBoot打包插件,可以将代码打包成一个可执行的jar包 -->
48     <build>
49         <plugins>
50             <plugin>
51                 <groupId>org.springframework.boot</groupId>
52                 <artifactId>spring-boot-maven-plugin</artifactId>
53             </plugin>
54         </plugins>
55     </build>
56 
57 </project>
View Code

相关文章:

  • 2021-06-27
  • 2021-08-15
  • 2021-05-25
  • 2022-12-23
  • 2021-03-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-23
  • 2021-12-25
  • 2021-10-08
  • 2022-01-25
  • 2022-01-16
  • 2018-11-28
  • 2021-08-07
相关资源
相似解决方案