上一篇已经写过如何搭建注册中心eureka,这一篇主要是搭建一些公共的api接口服务,并把实体类单独拿出来放到一个服务上引用,比较简单的

1、首先。创建一个实体类服务,这样就不用在每个服务里创建实体了,只需要把实体的依赖加入到pom.xml中就可以引用,

可以实现各服务间实体共享,这里的服务命名为study-entity,不需要添加任何配置,结构如下:

 2、在pom.xml中加入依赖,在依赖中要依赖父项目,这样一个封装实体的服务就创建好了

<!--父项目依赖-->
<parent>
<groupId>com.study</groupId>
<artifactId>study-cloud</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../study-cloud/pom.xml </relativePath><!-- lookup parent from repository -->
</parent> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>

3、创建api服务,命名为study-api,主要是是用于管理接口,供其他服务之间可以相互调用,结构同上,不需要配置文件

 4、添加study-api的pom.xml依赖,引入父项目依赖,和实体依赖

    <!--父项目-->
<parent>
<groupId>com.study</groupId>
<artifactId>study-cloud</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../study-cloud/pom.xml </relativePath><!-- lookup parent from repository -->
</parent>
<groupId>com.study</groupId>
<artifactId>study-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>study-api</name>
<description>Demo project for Spring Boot</description> <dependencies>
<!--实体引入-->
<dependency>
<groupId>com.study</groupId>
<artifactId>study-entity</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

5、最后,看下study-cloud父工程,创建项目时,以study-cloud作为父项目的都会在父项目中出现自动引入

 6、创建完成,这两个服务以后编码的过程中会用到,所以不想写测试代码,没有测试结果哦

最新文章

  1. Uva 10891 经典博弈区间DP
  2. python Django教程 之 模型(数据库)、自定义Field、数据表更改、QuerySet API
  3. [转]用Python读写Excel文件
  4. SharePoint Client Add Folder,file to Library
  5. linux elinks命令
  6. UNIX基础--Shells
  7. ASP.NET MVC5 实现分页查询
  8. (转)Eclipse中自动添加注释(作者,时间)
  9. MongoDB分组
  10. 百度搜索(jsonp)
  11. 【10】Cookie和Session
  12. hibernate 集合查询
  13. 使用Elasticsearch 出现的拒绝连接
  14. Linux中符号总结
  15. Win10系列:VC++数据绑定
  16. 【FRM123】Wrong Way Risk
  17. ubuntu , 笔记本合上盖子时不关机的方法。
  18. jquery中的data-icon和data-role
  19. ios开发者较为好用的工具
  20. python 之 赋值和拷贝(你真的了解吗)

热门文章

  1. 牛客-富豪凯匹配串(bitset)
  2. 计算 $s=1+(1+2)+(1+2+3)+\cdots+(1+2+3+\cdots+n)$
  3. as和强制类型转换的区别
  4. kafka spark steam 写入elasticsearch的部分问题
  5. SecureCRT8.1安装破解
  6. leaflet本地加载arcgis切片
  7. 17)将index.php中的代码放到Framework中封装起来
  8. Protein interaction|insight QUANTA|SYBYL COMPOSER|MODELLER|SWISS_MODEL|WHAT IF|3D-JIGSAW|CPH-ModelGPCRs|Membrane protein|
  9. Java反射的实例
  10. Selenium2自动化——初体验