retrofit:一套RESTful架构的Android(Java)客户端实现。

好处:

  • 基于注解
  • 提供JSON to POJOPOJO to JSON网络请求(POST,GET,PUT,DELETE等)封装
  • 可以看做是对HttpClient的再次封装

1、为了做测试,建立了一个新的springboot项目"myboot2",项目结构如下:

第七章 springboot + retrofit

1.1、pom.xml

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 4 
 5     <modelVersion>4.0.0</modelVersion>
 6 
 7     <groupId>com.xxx</groupId>
 8     <artifactId>myboot2</artifactId>
 9     <version>1.0-SNAPSHOT</version>
10 
11     <properties>
12         <java.version>1.8</java.version><!-- 官方推荐 -->
13     </properties>
14     
15     <parent> 
16         <groupId>org.springframework.boot</groupId> 
17         <artifactId>spring-boot-starter-parent</artifactId> 
18         <version>1.2.5.RELEASE</version> 
19     </parent>
20 
21     <!-- 引入实际依赖 -->
22     <dependencies>
23         <dependency>
24             <groupId>org.springframework.boot</groupId>
25             <artifactId>spring-boot-starter-web</artifactId>
26         </dependency>
27         <!-- 使用swagger -->
28         <dependency>
29            <groupId>io.springfox</groupId>
30            <artifactId>springfox-swagger2</artifactId>
31            <version>2.2.2</version>
32         </dependency>
33         <dependency>
34            <groupId>io.springfox</groupId>
35            <artifactId>springfox-swagger-ui</artifactId>
36            <version>2.2.2</version>
37         </dependency>
38     </dependencies>
39 
40     <build>
41         <plugins>
42             <plugin>
43                 <groupId>org.springframework.boot</groupId>
44                 <artifactId>spring-boot-maven-plugin</artifactId>
45             </plugin>
46         </plugins>
47     </build>
48 </project>
View Code

相关文章:

  • 2022-01-10
  • 2022-01-27
  • 2021-05-10
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2021-09-01
  • 2021-07-20
  • 2021-09-14
  • 2021-12-18
相关资源
相似解决方案