我正在尝试将Spring Boot后端连接到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
答案 0 :(得分:1)
在driverClassName
下添加spring.datasource
属性。你应该得到这样的东西
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