【SpringBoot】⑩SpringBoot与热部署,监控

实际2020-05-13 08:56:19
此篇文章使用版本:2.2.2.RELEASE
热部署 源码
监控 源码

热部署

1)、加入依赖

1
2
3
4
5
<!--热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>

2)、修改了之后,使用Ctrl + F9使修改生效。也就是构建项目的快捷键。
在这里插入图片描述

3)、这里我添加了快捷键F5,使用Ctrl + F9F5都可以构建。
设置编辑器的快捷键

监控

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
2022-11-02 09:45:35 补

# actuator 应用监控
<!--actuator 应用监控-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

### actuator
management.endpoint.metrics.enabled = true
management.endpoint.prometheus.enabled = true
management.endpoints.web.exposure.include = *
management.metrics.export.prometheus.enabled = true
management.metrics.tags.application = ${spring.application.name}
management.health.redis.enabled = false
management.health.ldap.enabled = false

# prometheus
可选择 => 例如 http://10.11.12.232:18003/actuator/prometheus
<!--prometheus 监控采集-->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.8.2</version>
</dependency>

// fastjson 访问不了 prometheus 问题
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.QuoteFieldNames,
SerializerFeature.WriteEnumUsingToString,
SerializerFeature.WriteMapNullValue,
SerializerFeature.WriteDateUseDateFormat,
SerializerFeature.DisableCircularReferenceDetect);
fastConverter.setFastJsonConfig(fastJsonConfig);
converters.add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
converters.add(1, fastConverter);
}
}