更改dispatcherServlet url映射后未找到Spring执行器终结点

更改dispatcherServlet url映射后未找到Spring执行器终结点,spring,spring-mvc,spring-boot,Spring,Spring Mvc,Spring Boot,我用弹簧靴和弹簧执行器开发了我的第一个rest服务。我需要将servlet映射更改为另一个。因此,我的代码在@Configuration类中如下所示: @Bean public DispatcherServlet dispatcherServlet() { return new DispatcherServlet(); } @Bean public ServletRegistrationBean dispatcherRegistration(final DispatcherServle

我用弹簧靴和弹簧执行器开发了我的第一个rest服务。我需要将servlet映射更改为另一个。因此,我的代码在@Configuration类中如下所示:

@Bean
public DispatcherServlet dispatcherServlet() {
    return new DispatcherServlet();
}

@Bean
public ServletRegistrationBean dispatcherRegistration(final DispatcherServlet dispatcherServlet) {
    final ServletRegistrationBean registration = new ServletRegistrationBean(dispatcherServlet);
    registration.addUrlMappings("/api/*");
    return registration;
}
服务端点工作正常,因为我在application.properties中排除了基本安全性:

security.ignored = **/directdebit/**
问题是我无法到达执行器端点。当我尝试localhost:8080/api/info时,我得到一个404未找到错误代码,并得到一个包含以下数据的审核事件:

AuditEvent [timestamp=Thu Sep 11 12:12:29 CEST 2014, principal=anonymousUser, type=AUTHORIZATION_FAILURE, data={message=Access is denied, type=org.springframework.security.access.AccessDeniedException}]
更新

从类路径中删除Spring安全性后,我可以访问localhost:8080/api/info。因此,当在类路径中找到Spring安全性时,问题与应用于管理端点的安全性有关

更新

仍在与此抗争。我已将字符串安全性恢复到类路径,并且从堆栈跟踪中可以看到未找到映射:

2014-09-16 11:01:09.011 DEBUG 780 --- [nio-8080-exec-2] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/mappings']
2014-09-16 11:01:09.011 DEBUG 780 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/mappings'; against '/mappings'
2014-09-16 11:01:09.011 DEBUG 780 --- [nio-8080-exec-2] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/mappings/']
2014-09-16 11:01:09.011 DEBUG 780 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/mappings'; against '/mappings/'
2014-09-16 11:01:09.011 DEBUG 780 --- [nio-8080-exec-2] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/mappings.*']
2014-09-16 11:01:09.012 DEBUG 780 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/mappings'; against '/mappings.*'
2014-09-16 11:01:09.012 DEBUG 780 --- [nio-8080-exec-2] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2014-09-16 11:01:09.012 DEBUG 780 --- [nio-8080-exec-2] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/**']
2014-09-16 11:01:09.012 DEBUG 780 --- [nio-8080-exec-2] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request '/api/mappings' matched by universal pattern '/**'
2014-09-16 11:01:09.012 DEBUG 780 --- [nio-8080-exec-2] o.s.s.web.util.matcher.OrRequestMatcher  : matched

如果servlet上下文路径不是“/”,则管理端点似乎已断开。因此,问题是如何使执行器管理端点知道servlet上下文路径?

执行器端点的映射与DispatcherServlet不同。您可以使用应用程序属性management.contextPath(默认为“/”)更改执行器端点的路径。例如,您应该能够使用localhost:8080/info访问端点。

如果我尝试使用localhost:8080/info,我也会得到404,但没有AuditEvent。如果我尝试使用localhost:8080/api/info,我会得到一个404和前面提到的AuditEvent。我认为这与安全有关。