SpringBoot配置数据源失败



我目前正在学习微服务。在创建我的第一个微服务后,我试图将我的微服务连接到PostgreSQL数据库,但我有以下错误:

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

在上下文初始化时遇到异常-取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为"dataSourceScriptDatabaseInitializer"的bean时出错在类路径资源中定义[org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]:通过方法表示的不满意的依赖关系'dataSourceScriptDatabaseInitializer'参数0;嵌套异常是org.springframework.beans.factory.BeanCreationException:错误创建在类路径资源中定义名称为'dataSource'的bean(org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration Hikari.class美元):通过工厂方法进行Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException: Failed to(com.zaxxer.hikari实例化。hikaridatassource]:工厂方法'数据源'抛出异常;嵌套异常是org.springframework.boot.autoconfigure.jdbc.DataSourceProperties DataSourceBeanCreationException美元:日志含义确定合适的驱动类失败
2022-12-06 22:33:04.408 INFO 2012—[main] .apache.catalina.core. standardservice:停止服务[Tomcat]

这是我的application.yml

server:
port: 8080
spring:
application:
name: player
datasource:
password: "MySecretPassword!"
url: jdbc:postgresql://localhost:5432/genjiservices
username: saucegenji
jpa:
hibernate:
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
format_sql: true
show-sql: true

我不能发表我的诗歌,因为它说这是垃圾邮件。

我试着先找到解决方案,但找不到一个适合我的。我觉得我的应用程序忽略了我的应用程序。可能是这样吗?我的应用程序。

检查pom文件中是否存在以下内容。还要检查pom中的JPA依赖项。

<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>

相关内容

最新更新