SpringBoot基于Actuator远程关闭服务
1、在pom.xml文件引入依赖
<!-- 运行状态监控actuator依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
2、配置文件配置
server: port: 8100 #web服务端口 servlet: context-path: /buzhengspring: main: allow-bean-definition-overriding: true #是否允许使用相同名称重新注册不同的bean实现. 默认是允许 datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&useSSL=false&serverTimezone=Asia/Shanghai username: root password: asdfghjkl### 运行状态监控Actuatormanagement: server: port: 9011 #运行状态监控端口 endpoints: web: exposure: include: '*' base-path: / #配置可远程使用 Actuator 关闭服务 endpoint: shutdown: #关闭服务 enabled: true
3、执行关闭指令
http://localhost:9011/shutdown POST请求
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持好吧啦网。
相关文章:
1. 详解springBoot启动时找不到或无法加载主类解决办法2. Python解释器及PyCharm工具安装过程3. 正则表达式匹配${key}并在Java中使用的详细方法4. Python通过fnmatch模块实现文件名匹配5. IntelliJ IDEA删除类的方法步骤6. JAVA教程:解析Java的多线程机制(1)7. python 解决pycharm运行py文件只有unittest选项的问题8. 关于python中readlines函数的参数hint的相关知识总结9. Android Studio 4.0 正式发布在Ubuntu 20.04中安装的方法10. iOS中各种UI控件属性设置示例代码
