Help us understand the problem. What is going on with this article?

Spring Boot 2.0 (Spring 5) の WebMvcConfigurer覚書

More than 1 year has passed since last update.

はじめに

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

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

Javadoc先生が教えてくれた

https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapter.html

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もエラーだわっしょい!

yukina-ge
基本Javaの案件ばかりやってます。 今はお仕事でAWSをつかった動画配信コンテンツを作っています。
genuine
確かな技術力と誠実な人間力、ユーザー目線の業務スキルで本当に必要とされるシステムを構築する会社です。
https://genuine-pt.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした