zoukankan      html  css  js  c++  java
  • springboot 停止

    因springboot内嵌tomcat或jetty使得我们没法去操作服务:

    因此,常常是服务起来后,要重启时会端口占用,我们只能无情的kill掉端口。

    不过spring也设置有配置停止的请求:

    Application.properties中添加:

    endpoints.shutdown.enabled=true
    endpoints.shutdown.sensitive=false

    在pom.xml中添加:

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

    此时,需要停止服务时,只需要在网页上以post的形式请求:

      http://ip:port/shutdown

    也可通过控制台:

    >curl -X POST http://127.0.0.1:8081/shutdown

     最后结果为: {"message":"Shutting down, bye..."}

    以上的停止方式不安全,会导致任何人都可以进行操作。因此需要添加安全限制。

    endpoints.shutdown.enabled=true
    endpoints.shutdown.sensitive=true
    endpoints.shutdown.path=shutdown
    security.user.name=root
    security.user.password=denny#2018
    management.security.role=SUPERUSER
    management.context-path=/manage
    #management.port=8080
    #management.address=192.168.204.21

    在pom.xml中添加security的服务:

         <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
  • 相关阅读:
    linux线程
    linux线程
    c++之堆、栈、数据段、
    fork()、僵死进程和孤儿进程
    linux之管理mysql
    linux之管理apache
    Django 时间与时区设置问题
    Django rest framework:__str__ returned non-string (type NoneType) 真正原因
    Django获取当前页面的URL——小记
    Django中出现:TemplateDoesNotExist at
  • 原文地址:https://www.cnblogs.com/DennyZhao/p/9407475.html
Copyright © 2011-2022 走看看