如何正确停止springboot项目?

这是面试时被问到的一个问题,后来在网上搜索了很多,我用了看起来比较简便的一种方法,就是这个链接中的方式一:正确、安全地停止SpringBoot应用服务
总共就三步:1.导入actuator依赖;2.配置properties文件;3.使用post方式发出shutdown信号

然而我得到的响应是这样的:QQ图片20191108164254.png,显然项目并没有终止

我是在windows上用idea直接启动的,用postman发出的post请求,
properties文件有个这样的报错:Deprecated: Endpoint sensitive flag is no longer customizable as Spring Boot no longer provides a customizable security auto-configuration,是版本问题吗?
我的项目端口是80,使用默认的http://localhost/actuator/shu...
访问还是会出现同样的问题

回答:

你的url地址有问题,默认是http://host:port/actuator/shutdown。然后如果仅是这样会有安全问题,最好自定义一下路径再仅接收本地IP访问。

回答:

直接 kill (没有-9)肯定不是一个错误的方式
spring-boot的配置是这样的

management.endpoints.web.exposure.include=*

management.endpoint.shutdown.enabled=true

然后 访问 /actuator/shutdown 就行了

以上是 如何正确停止springboot项目? 的全部内容, 来源链接: utcz.com/p/181728.html

回到顶部