一、搭建Eureka服务
1、利用maven构建工具,快速搭建spring boot项目
1.1:(输入相关项目名称,选择相关依赖等)
将压缩包解压到顺手的盘,用编辑器打开。
1.2:完善相关pom文件和配置文件application.properties
此处搭建的是一个Eureka服务和两个spring服务,效果如图:
生成的项目目录如下:
具体pox.xml配置和application.properties参考https://blog.csdn.net/u010938610/article/details/79282624
2、搭建过程中需要注意的问题
Spring Boot和Spring Cloud之间的版本对应关系
Spring Boot | Spring Cloud |
---|---|
1.2.x | Angel版本 |
1.3.x | Brixton版本 |
1.4.x | Camden版本 |
1.5.x | Dalston版本、Edgware版本 |
2.0.x | Finchley版本 |
当依赖间版本无法对应时会导致 : java.lang.NoSuchMethodError 异常,具体对应关系参考上图。
附上本人搭建时用的版本:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Finchley.SR2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
传送门:https://search.maven.org/ 查找相关版本信息