cloud 启动报错:If you want an embedded database please put a supported one on the classpath
程序员文章站
2022-04-19 22:39:42
...
原因:在父pom中引入了jdbc和mysql相关依赖,如下:
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.16</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
启动不需要连接数据库的子项目,就会报这个错:
Description:
Cannot determine embedded database driver class for database type NONE
Action:
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).
解决办法:在启动类的@EnableAutoConfiguration或@SpringBootApplication中添加exclude = {DataSourceAutoConfiguration.class},排除此类的autoconfig。启动以后就可以正常运行。排除数据库的自动启动;如下
//@SpringBootApplication
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) //因在父项目的pom中添加了连接数据库相关的pom,所以每一个不需要连接数据库的子项目都需要加这个
@EnableEurekaServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
推荐阅读
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
-
If you want an embedded database please put a supported one on the classpath
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath..
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
-
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath
-
cloud 启动报错:If you want an embedded database please put a supported one on the classpath
-
If you want an embedded database please put a supported one on the classpath
-
If you want an embedded database please put a supported one on the classpath
-
spring boot 启动报If you want an embedded database please put a supported one on the classpath
-
配置SpringCloud时错误:If you want an embedded database please put a supported one on the classpath