我正在用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发布于 2021-04-20 18:52:28
试着使用
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect或您的项目的其他方言版本
发布于 2021-04-19 15:04:25
要使用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>请按照步骤操作,如果遇到任何问题,请让我们知道
https://stackoverflow.com/questions/67155691
复制相似问题