其他分享
首页 > 其他分享> > SpringBoot 2.0.1中未提供执行器/刷新

SpringBoot 2.0.1中未提供执行器/刷新

作者:互联网

我正在为Spring-Config-Server和Spring-Config-Client创建一个演示项目.

在SpringBoot 1.5.6.RELEASE中一切正常.

但是,当我将项目升级到2.0.1.RELEASE时,它不提供执行器端点.

执行器端点在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

执行器端点在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>

bw 1.5.6 pom的唯一区别是版本和spring-cloud.version = Dalston.SR2

有人可以帮忙吗?

解决方法:

经过一番研究,我发现Spring Boot 2.0中没有显示端点的原因是as per docs

By default, all endpoints except for shutdown are enabled

所以,我们需要手动启用它们.

我在application.properties文件中添加了management.endpoints.web.exposure.include = *,现在所有的端点都回来了.

注意:如果您使用的是.yml,请确保使用“*”而不是*

标签:spring-boot-actuator,spring-cloud-config,spring,spring-boot,spring-cloud
来源: https://codeday.me/bug/20190930/1837126.html