SpringBoot2.0以上整合EurekaServer 時,經過自己的一通配置操作後,在運作是出現如下報錯:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-08-05 10:56:04,870 ERROR [LoggingFailureAnalysisReporter.java:42] :
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:。。。。。。。。。。。。。。。。。。
,剛開始确實一臉懵逼,查詢了很多部落格,都沒有得到解決,最後我考慮到了SpringBoot與SpringCloud版本适配問題,于是就找到了官網的版本對照如下:
當察覺到版本問題後,又是一通查部落格,就總結了一下:
Spring cloud 與 Spring boot 版本對照:
Hoxton 2.2.x
Greenwich 2.1.x
Finchley 2.0.x
Edgware 1.5.x
Dalston 1.5.x
#其他寫法
Angel版本對應Spring Boot 1.2.x
Brixton版本對應Spring Boot 1.3.x
Camden版本對應Spring Boot 1.4.x
Dalston 版本對應Spring Boot 1.5.x
Edgware 版本對應Spring Boot 1.5.x
Finchley 版本對應Spring Boot 2.0.x
Greenwich 版本對應Spring Boot 2.1.x
詳細對照參考官網:https://spring.io/projects/spring-cloud
按照版本對應,修改了自己的pom檔案,最後成功啟動,問題解決。
本人詳細Demo如下:
pom.xml:
<?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 https://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.1.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ellisonpei</groupId>
<artifactId>eureka</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eureka</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
<!-- <spring-cloud.version>Finchley.RELEASE</spring-cloud.version> 對應2.0版本的boot-->
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</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>
application.yml:
spring:
freemarker:
#template-loader-path: classpath:/templates/
prefer-file-system-access: false
application:
#設定服務名
name: eureka-server
#指定服務的端口
server:
port: 8761
#配置eureka資訊
eureka:
instance:
hostname: localhost
client:
#是否注冊自身到eureka伺服器
register-with-eureka: false
#是否從eureka伺服器擷取注冊資訊
fetch-registry: false
#設定eureka伺服器所在的位址,查詢服務和注冊服務都需要依賴這個位址
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
EurekaApplication.class啟動類:
運作成功:
之後浏覽器通路:http://localhost:8761