英文:
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: 'url' 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
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
答案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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论