2-5 api接口的暴漏
所有的接口服务接口都在service-api子工程管理
因为微服务项目 很多controller分散在不同的子工程中 很难统一查看和管理
其次 以后如果spring boot这项技术慢慢的变得不流行之后 重构项目时 不用接口 而直接修改实现即可 这样就实现了解耦
微服务也是基于接口来调用的
swagger 是基于接口自动生成文档的
在api接口中导入spring-boot的依赖
<dependencies>
<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>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
</dependencies>
创建user-service包并创建接口

service直接实现接口即可

虽然道路是曲折的,但前途是光明的。

浙公网安备 33010602011771号