1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Java/Spring Bootのおさらいメモ

Posted at

はじめに

最終目標:クライアントからもらったパラメータをサーバ側でDBに問い合わせて計算とかやってレスポンスするとこまで実装したい

現状:Springスタータープロジェクトとやらを使って動かそうとしたらNo suitable driverとか出てきたので解決したところ

環境設定

環境情報
・Java:OpenJDK 17.0.7
・DB:PostgreSQL 15.3
applicationファイルにJDBC接続情報を設定
公式ドキュメントの情報が間違いないので迷ったら以下を参照
applicationファイル公式ドキュメント

ドライバが見つからないとのことなので、以下の設定を書き込む


spring:
    datasource:
        url: jdbc:postgresql://localhost:5432/TEST
        username: postgres
        password: root
        driverClassName: org.postgresql.Driver

※補足_各設定項目について
url→接続先のDB情報を指定
username→DBのユーザー名を指定
password→パスワード
driverClassName→クラスパスを設定したjarファイル(JDBCドライバ)のDriverクラスの名前空間を指定

※補足_propertiesとymlについて
Spring Bootでは、applicationファイルからJDBC接続の設定などを行う。
applicationファイルには「properties」と「yml」の2つの形式がある。
どっちにするかはその場のルールや好みで決める。今回はymlを適用していく。

以上でjdbcドライバの設定は完了。
postgresを立ち上げ、実行したらうまくいくはず...
実行!

image.png
おぉっ!No suitableが表示されなくなったっ!!
ということで、環境構築引き続き頑張ります。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?