gpt4 book ai didi

java - 配置数据源失败

转载 作者:行者123 更新时间:2023-11-29 09:31:04 25 4
gpt4 key购买 nike

我正在尝试使用 mysql 数据库运行 Spring boot 程序。当我尝试运行该程序时,我得到以下信息:

我尝试了一些解决方案,例如编辑我的 pom.xml 文件和 application.program 文件,但还没有任何解决方案适合我。

***************************
APPLICATION FAILED TO START
***************************

Description:

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


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).

pom.xml 依赖项:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>

最佳答案

根据日志,您必须添加到 src/main/resources/application.properties : spring.datasource.url=jdbc:mysql:jdbc:mysql://localhost:3306/[your_database]
spring.datasource.username=[username]
spring.datasource.password=[password]

关于java - 配置数据源失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58704064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com