我只是迁移到Spring 5.0.1.RELEASEMVC 版本,但突然在Eclipse STS中将WebMvcConfigurerAdapter标记为已弃用
5.0.1.RELEASE
public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/resources/**").addResourceLocations("/resources/"); // to serve static .html pages... registry.addResourceHandler("/static/**").addResourceLocations("/resources/static/"); } .... }
我该如何删除!
从Spring 5开始,你只需要实现接口WebMvcConfigurer:
WebMvcConfigurer:
public class MvcConfig implements WebMvcConfigurer {
这是因为Java 8在接口上引入了覆盖WebMvcConfigurerAdapter该类功能的默认方法
WebMvcConfigurerAdapter