私はHerokuにデプロイされたSpring Bootアプリを使って遊んでいましたが、解決策を見つけることができないというエラーが発生しました。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();
}
}
誰もが目で私を指すことができます右方向。私は間違って何をしていますか?
こんにちは、あなたは正しくのPostGreSQL JDBCドライバ(のpom.xml)のためにMavenの依存関係を追加しました:
は私が問題を解決したのpom.xmlに以下の依存関係を追加しましたか? 'はい - 私はまた、Mavenの依存性が – Alin
を追加していますが作成し、Herokuのコマンドラインを使用して、PostgreSQLサービスにバインドしましたか? $ heroku addons:add heroku-postgresql:hobby-dev –