在spring-webmvc中,AbstractHandlerMethodMapping.java中有一个参数detectHandlerMethodsInAncestorContexts
。
其默认值为false。如何设置为真?
最佳答案
只需显式创建RequestMappingHandlerMapping
bean并将此值设置为true
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
RequestMappingHandlerMapping requestMappingHandlerMapping = new RequestMappingHandlerMapping();
requestMappingHandlerMapping.setDetectHandlerMethodsInAncestorContexts(true);
return requestMappingHandlerMapping;
}