Spring Boot 2.6.6 へアップグレード
この記事を参考に、利用しているプロジェクトのSpring Bootのバージョンを2.6.6へアップグレードする
1. データベースへ接続無し
Spring BootのバージョンアップのみでOK
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>1.5.2.RELEASE</version> + <version>2.6.6</version> <relativePath/> <!-- lookup parent from repository --> </parent>
Application クラスへ @SpringBootApplication を付与する必要があった
+@SpringBootApplication -@EnableAutoConfiguration -@ComponentScan -@Configuration public class Application {
あと、src/main/resources/static/index.html を参照できなくなった
2. PostgreSQLへ接続
Spring Bootのバージョンアップに加え以下を実施
PostgreSQLへ接続するためのドライバが古かったので更新 大きな変更があると困るので、なるべく既存のものに近いものを選んだ
<dependency> - <groupId>postgresql</groupId> + <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> - <version>9.1-901-1.jdbc4</version> + <version>9.4.1212</version> </dependency>
RestTemplateBuilder の引数が long から Duration になった
restTemplate = restTemplateBuilder - .setConnectTimeout(3000) + .setConnectTimeout(Duration.ofMillis(3000)) - .setReadTimeout(3000) + .setReadTimeout(Duration.ofMillis(3000)) .build();
Thymeleafを利用
レイアウトが処理されないので、バージョンの指定を削除
<dependency> <groupId>nz.net.ultraq.thymeleaf</groupId> <artifactId>thymeleaf-layout-dialect</artifactId> - <version>2.4.1</version> </dependency>
レイアウトファイルの指定方法を変更
<html lang="ja" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" - layout:decorator="backend/layout"> + layout:decorate="backend/layout">
テスト
テストケースの@ContextConfiguration アノテーションの引数が変わった
-@ContextConfiguration(classes = Application.class, initializers = ConfigFileApplicationContextInitializer.class) +@ContextConfiguration(classes = Application.class, initializers = ConfigDataApplicationContextInitializer.class)
以下の定義を追加しないとJenkinsでテストが実行されない
<dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.8.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.8.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> <version>5.8.2</version> <scope>test</scope> </dependency>
spring-boot-starter-test があるから不要なんじゃないかと思い削除
-<dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> - <scope>test</scope> -</dependency>
その他
Beanの循環参照があったので見ないふり…
spring: main: + allow-circular-references: true
コンテキストパスの指定方法が変わった
-System.setProperty("server.context-path", "/path"); +System.setProperty("server.servlet.context-path", "/path");
EclipseでDoma2を使っていて、DAOクラスがコンパイルエラーになる
忘れた頃にお目にかかる問題 「Javaのビルドパス」の「除外」から「*/*」を消す
Spring Boot 2.6.6 へアップグレード
この記事を参考に、利用しているプロジェクトのSpring Bootのバージョンを2.6.6へアップグレードする
1. DB接続無しAPI
Spring BootのバージョンアップのみでOK
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>1.5.2.RELEASE</version> + <version>2.6.6</version> <relativePath/> <!-- lookup parent from repository --> </parent>
2. PostgreSQLへ接続
Spring Bootのバージョンアップに加え以下を実施
PostgreSQLへ接続するためのドライバが古かったので更新 大きな変更があると困るので、なるべく既存のものに近いものを選んだ
<dependency> - <groupId>postgresql</groupId> + <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> - <version>9.1-901-1.jdbc4</version> + <version>9.4.1212</version> </dependency>
spring-boot-starter-test があるから不要なんじゃないかと思い削除
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>
mod_disk_cacheのキャッシュが消されなくて困る
iowaitが一段落したのもつかの間、再びトラブル発生。
今度はディスクの残りがどんどん減り続ける。
htcachecleanをデーモンで動かしているので定期的に削除されるハズなのだけど、キャッシュするコンテンツを増やしたところ時間内に消しきれなくなった模様。
mod_mem_cacheを使うことも試したけど、有効期限が切れてもキャッシュが更新されないとかイロイロあり、検証に時間がとれないのでcronで片付けることに。
0 * * * * find /var/cacheroot -type f -mmin +30 -delete 30 * * * * find /var/cacheroot -type d -empty -delete
30分以内のキャッシュファイルを除いて全て削除するようにした。
これだと1時間でファイルを消しきれない場合同時に2つ動くこともあるけど、実害が出ていないのでとりあえず様子見。
webサーバのiowaitがやばい
apacheを動かしてるとあるサーバのiowaitが50を超えてた。
zabbixで確認すると21日まで普通に動いてるのに...
サーバにiotopが入ってないので調査に時間がかかる。
該当サーバではmod_disc_cacheを動かしているので、当初はこいつが原因かと思った。
キャッシュディレクトリを変えたところ負荷が下がったので様子見をしたけど、翌日また上がってきた。
ためしにキャッシュを無効にしても負荷が高いので不思議だったのだけど、どうやら原因は/usr/bin/updatedbぽい。
知識不足で恥ずかしいが、こいつはファイルの検索を早くするためインデックスを作成するらしい。
キャッシュディレクトリを処理対象から除外してみた。
これで、iowaitが20台に戻った。