简体   繁体   English

Spring 启动执行器未从指定端口启动

[英]Spring boot actuator not start with the port specified

I am trying to enable the actuator on an existing Spring Boot 2 application, which I thought would be straightforward as I have done few times for the application I created from scratch.我正在尝试在现有的 Spring Boot 2 应用程序上启用执行器,我认为这很简单,因为我已经为我从头开始创建的应用程序做了几次。 However, somehow tomcat (as default server) not startup with the actuator port configured in the properties, when the application starts.但是,当应用程序启动时,不知何故 tomcat(作为默认服务器)无法使用属性中配置的执行器端口启动。

Here are snippets of the config and pom这是配置和pom的片段

server:
  port: 8085
management:
  port: 9085


        <spring-boot.version>2.3.5.RELEASE</spring-boot.version>


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

In the log of application startup, I can see the server port has been bound to the application but didn't see the actuator one specified in the properties.在应用程序启动日志中,我可以看到服务器端口已绑定到应用程序,但没有看到属性中指定的执行器。

18:32:08.435 [main] INFO  o.a.c.h.Http11NioProtocol - Starting ProtocolHandler ["http-nio-8085"]
18:32:08.524 [main] INFO  o.s.b.w.e.t.TomcatWebServer - Tomcat started on port(s): 8085 (http) with context path ''

I would expect to see a port binding like the log below right after the one above.我希望在上面的日志之后看到一个端口绑定,如下面的日志。

2021-01-20 17:01:35.636  INFO 20044 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 9085 (http)

I have checked the port has not been used by any other application.我检查了该端口没有被任何其他应用程序使用。 Did I miss anything else?我还错过了什么吗?

From your posting info, you should add some setting to enable endpoints.从您的发布信息中,您应该添加一些设置以启用端点。 I give a sample.我给一个样品。 please try.请试试。 By another word, management.port is used in spring boot 1.x.换句话说,management.port 用于 spring boot 1.x。

In simple way, you just enable all endpoints and expose all.简单来说,您只需启用所有端点并公开所有端点。 for security reason, you should make management.endpoints.enabled-by-default to false.出于安全原因,您应该将 management.endpoints.enabled-by-default 设置为 false。 then enable endpoint you want to expose.然后启用要公开的端点。


management:
  server:
    port: 9085
  endpoints:
    enabled-by-default: true
    web:
#      base-path: /mgmt          # you can change /actuator to another name
      exposure:
        include: "*"
#  endpoint:
#    refresh:
#      enabled: true
#    loggers:
#      enabled: true
#    env:
#      enabled: true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM