首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配置DataSource失败:未使用Spring指定“url”属性

配置DataSource失败:未使用Spring指定“url”属性
EN

Stack Overflow用户
提问于 2020-09-17 08:24:53
回答 2查看 191关注 0票数 0

这是我第一次做一个简单的弹簧启动结块,我遇到了这个问题。

代码语言:javascript
复制
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class

我不知道如何解决我在驱动程序中添加的问题,但是我得到了错误,请解决这个问题

application.properties

代码语言:javascript
复制
spring.datasource.url=jdbc:mysql://localhost:3306/mlab
spring.datasource.username=root
spring.datasource.password=

porm.xml

代码语言:javascript
复制
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <scope>runtime</scope>
</dependency>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-09-17 08:31:44

看来你没能提供司机类的名字。

代码语言:javascript
复制
spring.datasource.url=jdbc:mysql://localhost:3306/mlab
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

您可以参考:https://www.baeldung.com/spring-boot-failed-to-configure-data-source

在添加上述属性之后,它应该是工作的。

票数 1
EN

Stack Overflow用户

发布于 2020-09-17 08:34:48

您可以尝试在application.properties中添加驱动程序类。

代码语言:javascript
复制
spring.datasource.driver-class-name=com.mysql.jdbc.Driver

您还可以根据需要添加以下内容并进行修改

代码语言:javascript
复制
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63934096

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档