无法配置数据源:未使用Spring Boot指定“url”属性。

huangapple go评论70阅读模式
英文:

Failed to configure a DataSource: 'url' attribute is not specified using Spring Boot

问题

这是我第一次进行简单的Spring Boot CRUD操作,我遇到了问题:

无法配置DataSource:未指定'url'属性且无法配置嵌入式数据源。
原因:无法确定合适的驱动程序类。

我不知道如何解决这个问题,我已经正确添加了驱动程序,但是仍然出现了错误,请帮我解决这个问题。

application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/mlab
spring.datasource.username=root
spring.datasource.password=

porm.xml

<dependency>
	<groupId>mysql</groupId>
	<artifactId>mysql-connector-java</artifactId>
	<scope>runtime</scope>
</dependency>
英文:

this is a first time i am doing a simple spring boot crud i ran in to the problem with

Failed to configure a DataSource: &#39;url&#39; attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class

i don't how to solve the problem I added in drivers correct way but I got the error pls solve this problem

application.properties

spring.datasource.url=jdbc:mysql://localhost:3306/mlab
spring.datasource.username=root
spring.datasource.password=

porm.xml

&lt;dependency&gt;
	&lt;groupId&gt;mysql&lt;/groupId&gt;
	&lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
	&lt;scope&gt;runtime&lt;/scope&gt;
&lt;/dependency&gt;

答案1

得分: 1

似乎您未提供驱动程序类名。

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

在添加了上述提到的属性后,应该可以正常工作。

英文:

It seems that you failed to provide driver-class name.

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

You can refer to : https://www.baeldung.com/spring-boot-failed-to-configure-data-source

It should be work after adding the above mentioned properties.

答案2

得分: 0

你可以尝试在 application.properties 文件中添加驱动程序类:

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

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

spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
英文:

You can try adding driver class in application.properties

spring.datasource.driver-class-name=com.mysql.jdbc.Driver

You can also add the following and modify as per your need

spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto = update

huangapple
  • 本文由 发表于 2020年9月17日 16:24:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/63934096.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定