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 –