Spring Boot执行器默认端点无法启动:/ info,/ metrics /,/ health

时间:2018-01-09 10:00:29

标签: rest spring-boot java-8

我正在运行Spring Boot 1.5.9-RELEASE应用。我使用了Pivotal的maven原型,其中包括spring boot& amp;弹簧致动器以及所有必要的依赖性。我还发布了启动日志的输出,并将org.springframework日志记录调到INFO级别。为什么这些默认端点根据spring docs应该开始没有启动?我真的很感激你的意见。我还发布了我的application.properties文件。当我在邮递员中点击终点时,我得到以下回复:

{
    "timestamp": 1515490133441,
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/info"
}

application.properties:

server.port=7299
security.user.password=password
num.to.output=1000
occurrence.of.garbage=9
endpoints.shutdown.enabled=true
endpoints.info.sensitive=false

启动日志的输出:

10:31:54,332 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
10:31:54,332 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback-test.xml]
10:31:54,332 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.xml] at [file:/Users/zenith/Documents/workspace/wsjoiner-service/target/classes/logback.xml]
10:31:54,382 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
10:31:54,383 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
10:31:54,388 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
10:31:54,424 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - This appender no longer admits a layout as a sub-component, set an encoder instead.
10:31:54,424 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - To ensure compatibility, wrapping your layout in LayoutWrappingEncoder.
10:31:54,424 |-WARN in ch.qos.logback.core.ConsoleAppender[STDOUT] - See also http://logback.qos.ch/codes.html#layoutInsteadOfEncoder for details
10:31:54,424 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
10:31:54,426 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [ROLLING_FILE]
10:31:54,430 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1073502961 - No compression will be used
10:31:54,431 |-INFO in c.q.l.core.rolling.TimeBasedRollingPolicy@1073502961 - Will use the pattern logs/WSJoinerServiceApp.%d{dd-MM-yyyy}.log for the active file
10:31:54,434 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - The date pattern is 'dd-MM-yyyy' from file name pattern 'logs/WSJoinerServiceApp.%d{dd-MM-yyyy}.log'.
10:31:54,434 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Roll-over at midnight.
10:31:54,436 |-INFO in c.q.l.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy - Setting initial period to Tue Jan 09 10:29:37 CET 2018
10:31:54,437 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
10:31:54,439 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ROLLING_FILE] - Active log file name: logs/WSJoinerServiceApp.log
10:31:54,439 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[ROLLING_FILE] - File property is set to [logs/WSJoinerServiceApp.log]
10:31:54,440 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework] to INFO
10:31:54,440 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [com.blairtech.wsjoiner] to INFO
10:31:54,440 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [com.blairtech.wsjoiner] to false
10:31:54,440 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[com.blairtech.wsjoiner]
10:31:54,441 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ROLLING_FILE] to Logger[com.blairtech.wsjoiner]
10:31:54,441 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to WARN
10:31:54,441 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
10:31:54,441 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ROLLING_FILE] to Logger[ROOT]
10:31:54,441 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
10:31:54,441 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@5e5792a0 - Registering current configuration as safe fallback point


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.9.RELEASE)

2018-01-09 10:31:54 [main] INFO  c.b.wsjoiner.WSJoinerServiceApp - Starting WSJoinerServiceApp on z-macdaddy.local with PID 24339 (/Users/zenith/Documents/workspace/wsjoiner-service/target/classes started by zenith in /Users/zenith/Documents/workspace/wsjoiner-service)
2018-01-09 10:31:54 [main] INFO  c.b.wsjoiner.WSJoinerServiceApp - No active profile set, falling back to default profiles: default
2018-01-09 10:31:54 [main] INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7fc2413d: startup date [Tue Jan 09 10:31:54 CET 2018]; root of context hierarchy
2018-01-09 10:31:54 [main] INFO  o.s.b.f.s.DefaultListableBeanFactory - Overriding bean definition for bean 'jsonResponseGenerator' with a different definition: replacing [Generic bean: class [com.blairtech.wsjoiner.response.JsonResponseGenerator]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/zenith/Documents/workspace/wsjoiner-io/target/classes/com/blairtech/wsjoiner/response/JsonResponseGenerator.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=WSJoinerIOConfig; factoryMethodName=jsonResponseGenerator; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/blairtech/wsjoiner/WSJoinerIOConfig.class]]
2018-01-09 10:31:54 [main] INFO  o.s.b.f.s.DefaultListableBeanFactory - Overriding bean definition for bean 'xmlResponseGenerator' with a different definition: replacing [Generic bean: class [com.blairtech.wsjoiner.response.XmlResponseGenerator]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/zenith/Documents/workspace/wsjoiner-io/target/classes/com/blairtech/wsjoiner/response/XmlResponseGenerator.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=WSJoinerIOConfig; factoryMethodName=xmlResponseGenerator; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/blairtech/wsjoiner/WSJoinerIOConfig.class]]
2018-01-09 10:31:55 [main] INFO  o.s.b.c.e.t.TomcatEmbeddedServletContainer - Tomcat initialized with port(s): 7299 (http)
2018-01-09 10:31:55 [localhost-startStop-1] INFO  o.s.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 870 ms
2018-01-09 10:31:55 [localhost-startStop-1] INFO  o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO  o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO  o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO  o.s.b.w.s.FilterRegistrationBean - Mapping filter: 'requestContextFilter' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO  o.s.b.w.s.DelegatingFilterProxyRegistrationBean - Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-01-09 10:31:55 [localhost-startStop-1] INFO  o.s.b.w.s.ServletRegistrationBean - Mapping servlet: 'dispatcherServlet' to [/]
2018-01-09 10:31:56 [main] INFO  o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7fc2413d: startup date [Tue Jan 09 10:31:54 CET 2018]; root of context hierarchy
2018-01-09 10:31:56 [main] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/sink/a],methods=[POST],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<com.blairtech.wsjoiner.messages.WSSinkResponseMessage> com.blairtech.wsjoiner.controller.WSJoinerSinkController.postRequest(com.blairtech.wsjoiner.messages.WSSinkInputMessage)
2018-01-09 10:31:56 [main] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/source/a],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.blairtech.wsjoiner.controller.WSJoinerSourceController.jsonRequest()
2018-01-09 10:31:56 [main] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/source/b],methods=[GET],produces=[application/xml]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.blairtech.wsjoiner.controller.WSJoinerSourceController.xmlRequest()
2018-01-09 10:31:56 [main] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-09 10:31:56 [main] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-09 10:31:56 [main] INFO  o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-09 10:31:56 [main] INFO  o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-09 10:31:56 [main] INFO  o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-09 10:31:56 [main] INFO  o.s.s.web.DefaultSecurityFilterChain - Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant [pattern='/js/**'], Ant [pattern='/images/**'], Ant [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant [pattern='/error']]], []
2018-01-09 10:31:56 [main] INFO  o.s.s.web.DefaultSecurityFilterChain - Creating filter chain: OrRequestMatcher [requestMatchers=[Ant [pattern='/**']]], [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6d171ce0, org.springframework.security.web.context.SecurityContextPersistenceFilter@5bb7643d, org.springframework.security.web.header.HeaderWriterFilter@2c306a57, org.springframework.security.web.authentication.logout.LogoutFilter@7a2e0858, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@6edcd0d8, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@4074023c, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5b12012e, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@22bd2039, org.springframework.security.web.session.SessionManagementFilter@38eb2fb0, org.springframework.security.web.access.ExceptionTranslationFilter@723ed581, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@9a2ec9b]
2018-01-09 10:31:56 [main] INFO  o.s.j.e.a.AnnotationMBeanExporter - Registering beans for JMX exposure on startup
2018-01-09 10:31:56 [main] INFO  o.s.b.c.e.t.TomcatEmbeddedServletContainer - Tomcat started on port(s): 7299 (http)
2018-01-09 10:31:56 [main] INFO  c.b.wsjoiner.WSJoinerServiceApp - Started 
WSJoinerServiceApp in 2.011 seconds (JVM running for 2.74)

1 个答案:

答案 0 :(得分:0)

如果您使用Spring Boot 1.5.9创建项目,并在http://start.spring.io/创建依赖项Web和Actuator,然后使用您的application.properties,则端点http://localhost:7299/info可用并返回

{}

因此,我建议您在http://start.spring.io/创建一个这样的项目,并将其与您的设置进行比较,或者直接从生成的项目开始。

执行器端点也列在日志中,日志中缺少此部分:

2018-01-10 08:46:36.840  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/shutdown || /shutdown.json],methods=[POST],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.ShutdownMvcEndpoint.invoke()
2018-01-10 08:46:36.841  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/configprops || /configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.846  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.get(java.lang.String)
2018-01-10 08:46:36.846  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)
2018-01-10 08:46:36.846  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/loggers || /loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.847  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
2018-01-10 08:46:36.848  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2018-01-10 08:46:36.850  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/env || /env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.854  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/autoconfig || /autoconfig.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.856  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2018-01-10 08:46:36.856  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/metrics || /metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.862  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/auditevents || /auditevents.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.boot.actuate.endpoint.mvc.AuditEventsMvcEndpoint.findByPrincipalAndAfterAndType(java.lang.String,java.util.Date,java.lang.String)
2018-01-10 08:46:36.863  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/trace || /trace.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.865  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/heapdump || /heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2018-01-10 08:46:36.866  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/mappings || /mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.868  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/beans || /beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.869  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/info || /info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-01-10 08:46:36.870  INFO 17243 --- [           main] o.s.b.a.e.mvc.EndpointHandlerMapping     : Mapped "{[/dump || /dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()