概要
SpringBootのversion 2.5が最近リリースされたようです。
劇的な変化があるのかはまだわかりませんが、application.ymlのspring.datasource.schema
やspring.datasource.data
、spring.datasource.initialization-mode
に該当する設定部分に警告が出ていたので、その対応(警告が出ないように対応)をしたのでメモとして残します。
警告の内容
以下のような警告が出ています。
内容を見ると、いずれも*** is Deprecated
となっているので、従来の設定が非推奨となったようです。
代わりにspring.sql.init.***
を使ってね。と丁寧に教えてくれているので、設定を変更してみます。
説明 リソース パス ロケーション タイプ
Property 'spring.datasource.data' is Deprecated: Use 'spring.sql.init.data-locations' instead. application-local.yml /restcontroller-sample/src/main/resources 行 32 言語サーバー
Property 'spring.datasource.initialization-mode' is Deprecated: Use 'spring.sql.init.enabled' instead. application-local.yml /restcontroller-sample/src/main/resources 行 33 言語サーバー
Property 'spring.datasource.schema' is Deprecated: Use 'spring.sql.init.schema-locations' instead. application-local.yml /restcontroller-sample/src/main/resources 行 31 言語サーバー
application.ymlの修正
以下のように修正することで、警告表示は消えました。
今までspring.datasource
にまとめて定義していたものを、分割するようになったんですね。
修正前
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=1;DB_CLOSE_ON_EXIT=FALSE;MODE=DB2
username: sa
password: ''
schema: classpath:develop-resources/schema.sql
data: classpath:develop-resources/data.sql
initialization-mode: always
修正後
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=1;DB_CLOSE_ON_EXIT=FALSE;MODE=DB2
username: sa
password: ''
sql:
init:
enabled: true
schema-locations: classpath:develop-resources/schema.sql
data-locations: classpath:develop-resources/data.sql