今天在搭建SpringCloud Eureka過程當中,一直在報pom依賴錯誤,排查問題總結以下經驗。java
一、SpringBoot整合SpringCloud二者版本是有嚴格約束的,詳細見SpringBoot官方文檔(https://spring.io/projects/spring-cloud):git
正確依賴示例:github
二、新版本的eureka server 的依賴artifactId已經變化,spring boot、spring cloud裏面不少包引用、包名等配置更新的很快,注意時刻關注官網。spring
<artifactId>spring-cloud-starter-eureka-server</artifactId> ---> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>apache
maven倉庫官方描述:https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-servermaven
三、maven jar包依賴錯誤,再次更新可能沒法下載正確的jar包,請刪除以前下載的jar包從新更新下載。spring-boot
四、正確的pom依賴示例以下:ui
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.github.gavincoder</groupId>
<artifactId>eureka-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eureka-server</name>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!--eureka-server服務端引入 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
<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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>