20、WebMvcConfigurerAdapter被Spring5.0弃用

在Spring5.0中,WebMvcConfigurerAdapter已经弃用,替代类:WebMvcConfigurationSupport或者DelegatingWebMvcConfiguration)

* extends WebMvcConfigurerAdapter+@EnableWebMvc 等同于 extends WebMvcConfigurationSupport

* 切勿使用@EnableWebMvc和 extends WebMvcConfigurationSupport 在一起。

package com.hbasesoft.vcc.sgp.ability.oauth.server.config;

import org.springframework.context.annotation.ComponentScan;

import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**

* @Author: fb

* @Description 配置页面视图

* (在Spring5.0中,WebMvcConfigurerAdapter已经弃用,替代类:WebMvcConfigurationSupport或者DelegatingWebMvcConfiguration)

*  extends WebMvcConfigurerAdapter+@EnableWebMvc 等同于 extends WebMvcConfigurationSupport

*  切勿使用@EnableWebMvc和 extends WebMvcConfigurationSupport 在一起

* @Date: Create in 9:36 2018/2/2

* @Modified By

*/

@Configuration

//@EnableWebMvc

@ComponentScan(basePackages = {"com.hbasesoft.vcc.sgp.ability.oauth.server"})

public class WebMvcConfig extends WebMvcConfigurationSupport {

    @Override

    protected void addViewControllers(ViewControllerRegistry registry) {

        registry.addViewController("/login").setViewName("authorize");

        //配置授权确认页面视图

        registry.addViewController("/oauth/confirm_access").setViewName("authorize");

    }

    @Override

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/index").addResourceLocations("/index.html");

    }

}

 

 

你可能感兴趣的:(spring,cloud)