【发布时间】:2021-11-22 09:25:09
【问题描述】:
当我运行我的 Spring Boot 项目时,我得到了这个错误:
说明:
未能配置数据源:未指定“url”属性并且 无法配置嵌入式数据源。
原因:无法确定合适的驱动程序类
行动:
考虑以下几点:
如果你想要一个嵌入式数据库(H2、HSQL 或 Derby),请把它放在 类路径。
如果您有要从特定配置文件加载的数据库设置 您可能需要激活它(当前没有激活的配置文件)。
我的 pom.xml 文件中有这个依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
当我尝试将 Spring Boot 版本更改为 2.5.5 时发生此错误。
【问题讨论】:
-
你的 jdbc url 是什么样子的?
-
jdbc:mysql://10.54.32.44:3306
-
所以你的 application.properties 中有 spring.datasource.url=jdbc:mysql://10.54.32.44:3306?
-
@Alien 不,它没有解决我的问题
标签: java spring spring-boot