我正在使用 mySQL 处理 Spring Boot 初始值设定项示例。
当我启动我的应用程序时,我收到以下错误。
这个问题有什么建议吗?
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
我试图运行这个!!!!
server.port=8081
spring.datasource.url=jdbc://localhost:3306/tp
spring.datasource.username=root
spring.datasource.password=
spring.jpa.show-sql= true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.hibernate.enable_lazy_load_no_trans=true
答案 0 :(得分:1)
尝试使用
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect
或您项目的其他方言版本
答案 1 :(得分:0)
使用 Mysql 开发 spring/boot 应用程序,然后按照以下步骤
Remove H2 Dependency From pom.xml
<!--
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
-->
Add a Dependency for MYSQL Database Connector to pom.xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<块引用>
在您的本地系统或任何远程位置设置您的 MySQL 数据库。
Configure application.properties to connect to your database.
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost:3306/<DBNAME>
spring.datasource.username=<USERNAME>
spring.datasource.password=<PASSWORD>
按照步骤操作,如有任何问题请告知我们