0
我一直在玩Heroku上部署的Spring Boot应用程序,但我偶然发现了一个我似乎无法找到解决方案的错误。春季启动连接到Heroku上的Postgres数据库
我试图连接到以下Heroku的教程(link)一个Postgres数据库,但我得到这个错误了一遍又一遍:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [javax.sql.DataSource]:
Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found
下面是我使用的配置文件:
spring.datasource.url=${JDBC_DATABASE_URL}
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.removeAbandoned=true
而且DatabaseConfig类:
@Configuration
public class DatabaseConfig {
@Bean @Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create()
.build();
}
}
任何人都可以点我在日正确的方向。我究竟做错了什么?
嗨,你有没有正确添加Maven的依赖关系为PostgreSQL的JDBC驱动程序(pom.xml的)? ' org.postgresql PostgreSQL的 9.4-1201-jdbc4 ' –
是 - 我也有Maven的依赖增加 – Alin
你创建和绑定使用Heroku的命令行PostgreSQL的服务? $ heroku addons:add heroku-postgresql:hobby-dev –