欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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);
    }
}

 

相关标签: 报错记录 Cloud