LoginSignup
20
18

More than 5 years have passed since last update.

Spring Boot 2.0 (Spring 5) の WebMvcConfigurer覚書

Last updated at Posted at 2018-03-07

はじめに

Spring Boot 1.5.10で作っていたアプリを勇んでSpring Boot 2.0 にしてみたらWebMvcConfigurerAdapterが非推奨になってしまったのでメモ。
Spring4 → Spring5になったからですね。

追記)2.0.0マイグレートに関するもろもろは こちらにまとめてみました。

Javadoc先生が教えてくれた

as of 5.0 WebMvcConfigurer has default methods (made possible by a Java 8 baseline) and can be implemented directly without the need for this adapter

なるほど、Spring5からはjava8以降が必須になったので、defaultメソッドが使えるようになったんだなぁ。

治療

変更前のWebMvcConfig.java

変更前のWebMvcConfig.java
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter
{
    // 略
}

変更後のWebMvcConfig.java

変更後のWebMvcConfig.java
@Configuration
public class WebMvcConfig implements WebMvcConfigurer
{
    // 略
}

これだけ。

おわり

余談

Thymeleafの自作Dialectもエラーだわっしょい!

20
18
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
20
18