Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
spring cloud的消费者启动时报错,无法决定driver class. 因为是消费者,不直接与数据库打交道,而是服务提供者负责与数据库打交道。正常流程是服务提供者查询数据库查到数据后提供给消费使用,消费者根据提供者的服务名,调用服务查询到数据,所以没有在消费者的module的pom.xml加入H2数据库的依赖,后面加上依赖后可以正常启动。
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>