[JAVA] Registration of multiple WebMvcConfigurers

I don't have much chance, but how to register multiple `` `WebMvcConfigurer``` in spring.

However, just prepare two implementation classes of WebMvcConfigurer. The read order is controlled by `@ Order``` and `@ DependsOn```.

pom.xml

pom.xml


	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.4.RELEASE</version>
	</parent>

Configuration

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Order(1)
public class FirstConfig implements WebMvcConfigurer {
    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        System.out.println("first");
    }
}

@Configuration
@Order(2)
public class SecondConfig implements WebMvcConfigurer {
    @Override
    public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
        System.out.println("second");
    }
}

There is no particular deep meaning, but the output is for checking the read order by overriding the appropriate method.

When executed, the following is displayed.

first
second

Recommended Posts

Registration of multiple WebMvcConfigurers
[Rails] List instances of multiple models
[Swift 5] Implementation of membership registration with Firebase
[Rails 6.0] About batch saving of multiple records
Uncertainty of common Jar for multiple versions
Find the difference from a multiple of 10