actuator /refresh is not being provided in SpringBoot 2.0.1

被刻印的时光 ゝ 提交于 2019-11-30 07:16:11

问题


I am creating a demo project for Spring-Config-Server and Spring-Config-Client.

In SpringBoot 1.5.6.RELEASE everything is working fine.

However, when I am upgrading project to 2.0.1.RELEASE it does not provide the actuator endpoints.


Actuator endpoint provided in 1.5.6.RELEASE

Mapped "{[/refresh || /refresh.json],methods=[POST]}"
Mapped "{[/dump || /dump.json],methods=[GET]
Mapped "{[/heapdump || /heapdump.json],methods=[GET]
Mapped "{[/autoconfig || /autoconfig.json],methods=[GET]
Mapped "{[/resume || /resume.json],methods=[POST]}"
Mapped "{[/configprops || /configprops.json],methods=[GET]
Mapped "{[/features || /features.json],methods=[GET]
Mapped "{[/loggers/{name:.*}],methods=[GET]
Mapped "{[/restart || /restart.json],methods=[POST]}"
...and many more

Actuator endpoint provided in 2.0.1.RELEASE

Mapped "{[/actuator/health],methods=[GET]
Mapped "{[/actuator/info],methods=[GET]
Mapped "{[/actuator],methods=[GET]

pom.xml : 2.0.1.RELEASE

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Finchley.RC1</spring-cloud.version>
    </properties>

<dependencies>
        <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>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-config</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

The only difference bw 1.5.6 pom is version and spring-cloud.version = Dalston.SR2

Could someone please help?


回答1:


After a bit of research, I have found the cause why the endpoints are not shown in Spring Boot 2.0 is as per docs

By default, all endpoints except for shutdown are enabled

so, we need to enable them manually.

I have added management.endpoints.web.exposure.include=* in application.properties file and now all the endpoints are back.

Note: If you are using .yml make sure to use "*" not *




回答2:


Exposure of endpoints on HTTP is now configurable by using properties

management.endpoints.web.exposure.include
management.endpoints.web.exposure.exclude

You can expose endpoints by there ID mentioned by Actuator.

# Include all endpoints 
management.endpoints.web.exposure.include=*
# Exclude specifics 
management.endpoints.web.exposure.exclude=env



回答3:


Even after adding the below line, wont help sometimes management.endpoints.web.exposure.include=*

Try this:- Refresh works on OPTIONS method, not with POST method for few cases.



来源:https://stackoverflow.com/questions/50114501/actuator-refresh-is-not-being-provided-in-springboot-2-0-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!