本文共 2552 字,大约阅读时间需要 8 分钟。
spring cloud项目需要依赖spring boot环境运行,在谁spring官网上可以发现二者的对应关系,在利用idea开发时,我们可以在父工程pom文档中管二者的版本号,以便于以后的开发和维护。
小编使用的spring boot版本号为2.1.2.RELEASE,spring cloud的版本号为:Greenwich.SR4
org.springframework.boot spring-boot-starter-parent 2.1.2.RELEASE org.springframework.cloud spring-cloud-dependencies Greenwich.SR4 pom import
org.springframework.cloud spring-cloud-starter-netflix-eureka-server
eureka客户需要管理eureka客户端本身的依赖,还需要有web应用和序列化的相关依赖。
小编用的缓存为redis,所以添加了spring boot自带的redis缓存依赖。
持久层方面,使用MySQL数据库,需要添加MySQL数据库连接依赖,持久层框架运用的是mybatis plus框架,引入了mybatis和spring boot整合的框架,另外添加了mybatis plus的自动生成代码块框架。连接池引入的是阿里的druid框架。
另外添加一个自己开发工厂依赖。
org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-web com.alibaba fastjson 1.2.54 org.springframework.boot spring-boot-starter-data-redis mysql mysql-connector-java 5.1.44 com.baomidou mybatis-plus-boot-starter 3.1.1 com.baomidou mybatis-plus-generator 3.3.1 com.alibaba druid 1.1.14 org.s2pe util 1.0-SNAPSHOT
网关工程和eureka工程类似,需要添加eureka客户端、redis缓存和web相关依赖,只是没有持久化应用,所以没有添加MySQL相关的一系列依赖。在此基础上,需要添加网关和负载均衡的依赖。
org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-data-redis org.springframework.boot spring-boot-starter-web org.springframework.cloud spring-cloud-starter-netflix-zuul org.springframework.cloud spring-cloud-starter-openfeign org.s2pe util 1.0-SNAPSHOT
转载地址:http://zntvb.baihongyu.com/