SpringBoot 3.4 to 3.5 メモ

SpringBoot 3.5がGAになりました。
Release Notesを参考に3.4系からの変更点をまとめます。
自分が移行するときに関係のあるものや興味があるものが中心となりますがご容赦ください🙇‍♂️

【デグレ注意】booleanのプロパティにon / offが指定不可能に

これまではbooleanのプロパティに on / off / true / falseが設定できました。

3.5からは true / falseのみになり、特にonを設定していた場合にはfalseで読み込みされるようになるとのことなので注意が必要です!

※ 試しにMybatis関連のプロパティでonを設定してみたけど、普通に動いた。。。
Release Noteだと .enableってワードがあるので特定のプロパティだけの適用なのかも? 🤔

【要修正】PushGateway利用時はライブラリを切り替え

dependencies {
  // before
  implementation 'io.prometheus:simpleclient_pushgateway'
  // after
  implementation 'io.prometheus:prometheus-metrics-exporter-pushgateway'
}

またプロパティの修正も必要になっています

management:
  prometheus:
    metrics:
      export:
        pushgateway:
          # before
          base-url: http://localhost:9091
          # after
          address: localhost:9091
          

【新機能】@FilterRegistration / @ServletRegistration

アノテーションを使用してFilterやServletを登録できるようになりました!

厳密にいうと今までも @Component 等でできたのですが、アノテーションを使用することで「特定のパスのみ適用」みたいなことが楽に実装できるようになりました!

@Configuration
public class SampleConfiguration {
    @Bean
    public String sampleBean() {
        return "This is a sample bean";
    }

    @Bean
    @FilterRegistration(urlPatterns = "/sample/*")
    public SampleFilter myFilter() {
        return new SampleFilter();
    }

    public static class SampleFilter implements Filter {
        @Override
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
            System.out.println("this is sample filter!");
        }
    }
}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です