Пружинный загрузочный привод — ошибка 404 даже при выполнении всех конфигураций

#spring #spring-boot #spring-boot-actuator

#пружинный #пружинная загрузка #пружинный загрузочный привод

Вопрос:

У меня есть этот проект spring boot, для которого мне нужно выполнить настройку привода.

pom.xml:

 <modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.3.RELEASE</version>
    <relativePath />
</parent>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
  

применение.свойства:

 server.port = 8099
management.endpoints.web.base-path=/manage
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
server.error.whitelabel.enabled=false
security.basic.enabled=false
management.security.enabled=false
  

корень контекста:

 System.setProperty("server.context-path", "/ims-web");
  

А теперь попробуйте использовать приведенные ниже URL GET -адреса. Каждый раз, когда я получаю тот же 404, не найден

  • http://localhost:8099/manage/health
  • http://localhost:8099/ims-web/manage/health
  • http://localhost:8099/ims-web/actuator/health
  • http://localhost:8099/actuator/health

Я что-то упускаю?

ОБНОВЛЕНИЕ 1: журналы запуска:

 SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/Maven/Dependencies/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/Maven/Dependencies/org/apache/logging/log4j/log4j-slf4j-impl/2.7/log4j-slf4j-impl-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
Ignoring Class-Path entry activation.jar found inD:MavenDependenciesjavaxmailmail1.4mail-1.4.jar as D:MavenDependenciesjavaxmailmail1.4activation.jar does not exist
20:37:28.476 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
20:37:28.483 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[w-] /, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
20:37:28.484 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/D:/EclipseWorkspaces/Workspace/ims-web/target/classes/, file:/D:/EclipseWorkspaces/Workspace/ims/target/classes/]

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

2020-09-25 20:37:29.108  INFO 272 --- [  restartedMain] com.cts.imsweb.ImsWebApplication         : Starting ImsWebApplication on PC1 with PID 272 (D:EclipseWorkspacesWorkspaceims-webtargetclasses started by Mike in D:EclipseWorkspacesWorkspaceims-web)
2020-09-25 20:37:29.110  INFO 272 --- [  restartedMain] com.cts.imsweb.ImsWebApplication         : No active profile set, falling back to default profiles: default
2020-09-25 20:37:29.656  INFO 272 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2c317ddc: startup date [Fri Sep 25 20:37:29 IST 2020]; root of context hierarchy
2020-09-25 20:37:31.703  INFO 272 --- [  restartedMain] o.s.b.f.xml.XmlBeanDefinitionReader      : Loading XML bean definitions from class path resource [applicationContext.xml]
2020-09-25 20:37:34.329  INFO 272 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8099 (http)
2020-09-25 20:37:34.349  INFO 272 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service Tomcat
2020-09-25 20:37:34.351  INFO 272 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.14
2020-09-25 20:37:34.703  INFO 272 --- [ost-startStop-1] o.a.c.c.C.[.[localhost].[/ims-web]       : Initializing Spring embedded WebApplicationContext
2020-09-25 20:37:34.703  INFO 272 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5047 ms
2020-09-25 20:37:35.626  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2020-09-25 20:37:35.633  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'metricsFilter' to: [/*]
2020-09-25 20:37:35.633  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2020-09-25 20:37:35.634  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2020-09-25 20:37:35.634  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2020-09-25 20:37:35.634  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2020-09-25 20:37:35.634  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2020-09-25 20:37:35.634  INFO 272 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'applicationContextIdFilter' to: [/*]
2020-09-25 20:37:36.360  INFO 272 --- [  restartedMain] o.s.j.d.DriverManagerDataSource          : Loaded JDBC driver: oracle.jdbc.driver.OracleDriver
2020-09-25 20:37:37.248  INFO 272 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@2c317ddc: startup date [Fri Sep 25 20:37:29 IST 2020]; root of context hierarchy
2020-09-25 20:37:37.373  INFO 272 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/products],methods=[POST],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<?> com.cts.imsweb.controller.ImsWebController.products()
2020-09-25 20:37:37.378  INFO 272 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.cts.imsweb.controller.WebController.home()
2020-09-25 20:37:37.378  INFO 272 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/404],methods=[GET]}" onto public java.lang.String com.cts.imsweb.controller.WebController.error404()
2020-09-25 20:37:37.379  INFO 272 --- [  restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/products],methods=[GET]}" onto public java.lang.String com.cts.imsweb.controller.WebController.products()
2020-09-25 20:37:37.386  INFO 272 --- [  restartedMain] 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)
2020-09-25 20:37:37.386  INFO 272 --- [  restartedMain] 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)
2020-09-25 20:37:37.424  INFO 272 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/products] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2020-09-25 20:37:37.424  INFO 272 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/404] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
2020-09-25 20:37:37.468  INFO 272 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-09-25 20:37:37.468  INFO 272 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-09-25 20:37:37.475  INFO 272 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler]
2020-09-25 20:37:37.587  INFO 272 --- [  restartedMain] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2020-09-25 20:37:39.116  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.118  INFO 272 --- [  restartedMain] 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)
2020-09-25 20:37:39.118  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.119  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.120  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.122  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.123  INFO 272 --- [  restartedMain] 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)
2020-09-25 20:37:39.124  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.125  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.128  INFO 272 --- [  restartedMain] 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
2020-09-25 20:37:39.129  INFO 272 --- [  restartedMain] 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)
2020-09-25 20:37:39.131  INFO 272 --- [  restartedMain] 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)
2020-09-25 20:37:39.132  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.135  INFO 272 --- [  restartedMain] 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)
2020-09-25 20:37:39.136  INFO 272 --- [  restartedMain] 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>)
2020-09-25 20:37:39.136  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.137  INFO 272 --- [  restartedMain] 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()
2020-09-25 20:37:39.591  INFO 272 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2020-09-25 20:37:40.068  INFO 272 --- [  restartedMain] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2020-09-25 20:37:40.087  INFO 272 --- [  restartedMain] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2020-09-25 20:37:40.398  INFO 272 --- [  restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8099 (http)
2020-09-25 20:37:40.407  INFO 272 --- [  restartedMain] com.cts.imsweb.ImsWebApplication         : Started ImsWebApplication in 11.883 seconds (JVM running for 15.683)
  

Комментарии:

1. Это было бы http://localhost:8099/ims-web/manage/actuator/health

2. Я получаю.. { «временная метка»: 1601046135004, «статус»: 404, «ошибка»: «Не найдено», «сообщение»: «Сообщение недоступно», «путь»: «/ims-web/manage/actuator/health» }

3. Вы проверяли журналы консоли при запуске вашего приложения? Это показывает привязку конечных точек

4. Обновлен вопрос с журналами для справки.

5. попробуйте http://localhost:8099/health , кажется, что то, что у вас есть в application.properties, не работает, просматривая журналы при запуске.

Ответ №1:

 server.port = 8099
management.endpoints.web.base-path=/manage
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
server.error.whitelabel.enabled=false
security.basic.enabled=false
management.security.enabled=false
server.servlet.context-path= /ims-web
  

Если вы используете context-path и web-base-path оба, то вы получите состояние работоспособности с:
http://localhost:8099/ims-web/manage/health

 #management.endpoints.web.base-path=/manage
  

Если вы не используете указанную выше строку, вы получите состояние работоспособности с:
http://localhost:8099/ims-web/actuator/health

 #server.servlet.context-path= /ims-web
  

Если вы откажетесь от context-path в своем коде, вы должны использовать:
http://localhost:8099/actuator/health

Ответ №2:

Как уже упоминалось, версия spring моего проекта была 1.5.3. Но я упомянул контекстный путь привода как:

 management.endpoints.web.base-path=/manage
  

Но для версий ниже 2x правильный формат:

 management.context-path=/manage
  

Это решило мою проблему.

Конечная точка теперь http://localhost:8099/ims-web/manage/health