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>
  • 相关阅读:
    子查询
    多表连接
    类型转换和其他函数
    亲测!Jquery2.0不支持IE8-了
    Sass结合Modernizr的使用方法
    子元素绝对定位撑不开父元素的解决方法
    ajax withCredentials在firefox下问题的解释
    记录遇到的IE8兼容性问题汇总
    对于requirejs AMD模块加载的理解
    requirejs 小结
  • 原文地址:https://www.cnblogs.com/DennyZhao/p/9407475.html
Copyright © 2011-2022 走看看