springboot主程序启动报错:inMemoryDatabaseShutdownExecutor报错

报错日志如下

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.mysql.cj.jdbc.Driver

在启动项上面的@SpringBootApplication注解改为:
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})再次运行。

该注解的作用是,排除自动注入数据源的配置(取消数据库配置),一般使用在客户端(消费者)服务中.
其他解决办法还说用:
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

你可能感兴趣的:(springboot主程序启动报错:inMemoryDatabaseShutdownExecutor报错)