spring 启动无法连接 spring 启动到 postgresql 数据库

spring boot cant connect spring boot to postgresql database

我正在尝试将 Spring 引导后端连接到 PostgreSQL,但出现此错误

***************************
APPLICATION FAILED TO START
***************************
Description:

Parameter 0 of constructor in 
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration 
required a bean of type 'javax.sql.DataSource' that could not be found.
- Bean method 'dataSource' not loaded because @ConditionalOnProperty 
(spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because @ConditionalOnBean (types: 
org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did 
not find any beans


Action:

Consider revisiting the conditions above or defining a bean of type 
'javax.sql.DataSource' in your configuration.

直到这一刻,我已经为这个错误苦苦挣扎了 2 天

我的 pom.xml

中有这些依赖项
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.4-1206-jdbc42</version>
    </dependency>

这是我的 application.yml

spring:
 jpa:
  database: POSTGRESQL
  show-sql: true
  hibernate:
    ddl-auto: create-drop
 datasource:
  platform: postgres
  url: jdbc:postgresql://localhost:5432/H4E
  username: postgres
  password: 123456

我正在使用带有 pgAdmin 3 LTS 的 PostgreSQL 10

spring.datasource下添加driverClassName属性。你应该得到这样的东西

spring:
    jpa:
        database: POSTGRESQL
        show-sql: true
        hibernate:
            ddl-auto: create-drop
    datasource:
        platform: postgres
        url: "jdbc:postgresql://localhost:5432/H4E"
        username: postgres
        password: 123456
        driverClassName: org.postgresql.Driver