当前位置: 首页 > 知识库问答 >
问题:

配置HTTPendpoint以关闭spring boot web应用程序

伯建安
2023-03-14

**

注意:当我尝试使用具有相同命令的Jenkins job关闭服务器时(并且运行的Jenkins服务器具有与本地服务器相同的pom和属性),我得到了以下异常:{“timestamp”:1515145896307,“status”:500,“error”:“internal server error”,“exception”:“java.lang.noClassDefounderRor”,“message”:“org/springframework/boot/actuate/endpoint/shutdownendpoint$1”,“path”:“/shutdowndownpoint$1”

我的pom.xml如下:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.springframework.samples</groupId>
    <artifactId>AllergiesConditions</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <!-- Generic properties -->
        <java.version>1.7</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.0.2</version>
        </dependency>

        <!-- Exclude Spring Boot's Default Logging -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-log4j2</artifactId>
        </dependency>


    </dependencies>

    <build>
        <finalName>AllergiesConditions</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

我的application.properties包括以下行:

server.port=8000
endpoints.shutdown.sensitive=false
endpoints.shutdown.enabled=true

共有1个答案

袁建木
2023-03-14

随着1.5版本的spring boot,我认为没有确定的关机机制。

您可以查看此链接,并了解如何在应用程序中正确地使用jmx或http关闭https://github.com/corentin59/spring-boot-graceful-shutdown。

祝你好运

 类似资料:
  • 问题内容: 如何在 不终止VM的情况下以* 编程方式关闭 Spring Boot 应用程序? * 在其他作品中, 问题答案: 关闭a 基本上意味着关闭基础。该方法为您提供了一个。您可以自己动手做。 例如, 或者,您可以使用 帮助程序方法来帮助您。例如,

  • 如何在不终止VM的情况下以编程方式关闭一个spring boot应用程序? 在其他作品中,…的反义词是什么

  • 启动 1. 轻触主画面上您想启动的应用程序图标。 显示LiveArea™。 2. 轻触[开始]。 中断/继续 按下PS键即可返回LiveArea™。若要继续,请轻触[继续]。 关闭 1. 按下PS键。 返回LiveArea™。 2. 请由画面右上角将LiveArea™撕下。

  • 我正在尝试使用我自己的应用程序实现或扩展的ResourceConfig或PackageResourceConfig来配置我的Jersey应用程序。因此,我的第一次尝试是将现有的web.xml(实际上,由于开发的库性质,我使用的是web-fragment.xml)配置移植到MyApplication实现。 当我使用第二个版本时,我会收到以下信息 正如您所看到的,是第一个注册的类,但由于它不是公共的,

  • 问题内容: 在我的Android应用程序中,我必须使用服务器上的JSON才能在应用程序中进行特定调整。我试图达到的目的是读取此json并将所有值存储到局部变量中以在应用程序内执行操作。 来自服务器的JSON: 为了进行解析,我创建了Parse JSON类,并尝试提出在我的应用中读取和存储此JSON值的方法。 执行此操作的功能: getJSONFromUrl方法: 我正在收到错误:在此但我已经定义了

  • 什么是最简单的方法,以获得Spring引导好,但不试图自动配置所有的东西?例如,要只使用我们已经配置的属性(一些通过Consul+Spring Cloud加载)运行flyway,我希望可以做一些类似的事情: 并且让main方法只调用 这样做的问题是,它会拾取所有的组件扫描/其他依赖项的长列表。任何具体配置依赖项的方法(但仍然获得框架的nicities)