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