首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我得到这个错误时,我试图午餐我的第一个项目与spring?

我得到这个错误时,我试图午餐我的第一个项目与spring?
EN

Stack Overflow用户
提问于 2021-04-19 11:42:36
回答 2查看 35关注 0票数 1

我正在用mySQL编写一个Spring Boot初始化器示例。

当我启动我的应用程序时,我得到了下面的错误。

对这个问题有什么建议吗?

代码语言:javascript
复制
***************************
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).

我试着运行它!

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

发布于 2021-04-20 18:52:28

试着使用

代码语言:javascript
复制
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect

或您的项目的其他方言版本

票数 1
EN

Stack Overflow用户

发布于 2021-04-19 15:04:25

要使用Mysql开发spring/boot应用程序,请执行以下步骤

代码语言:javascript
复制
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数据库。

代码语言:javascript
复制
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>

请按照步骤操作,如果遇到任何问题,请让我们知道

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67155691

复制
相关文章

相似问题

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