Spring Boot 健康检查配置及测试

  • 项目中添加actuator依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
  • 在浏览器中输入如下地址:

--[http://localhost/actuator] (http://localhost/actuator/hea...

*查看更多actuator选项
application.properties中添加如下语句:
management.endpoints.web.exposure.include=*

Spring Boot热部署配置及实现

*添加如下依赖,进行热部署实现。

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>

修改src/main/java目录下的java文件或修改src/main/resources目录下的配置文件时,默认都会重启你的web服务器,
但是修改测试类或html文件不会自动重启和部署。

Lombok插件应用

*作用:省略pojo类中的set方法,get方法,toString等方法的编写
*Lombok 常用注解分析:
@Setter 用于为描述的类生成setter方法,不包含final修饰属性
@Getter 用于为描述的类生成getter方法
@ToString 用于为描述的类添加toString方法

@EqualsAndHashCode 用于为描述的类,生成hashCode和equals方法
@NoArgsConstructor 用于为描述的类生成无参的构造方法
@AllArgsConstructor 用于为描述的类生成包含类中所有字段的构造方法
@Data 用于为描述的类生成setter/getter、equals、canEqual、hashCode、toString方法(为final属性,则不会为该属性生成setter方法)
@Slf4J 用于为描述的类添加一个日志属性对象

*JS中代码调试技巧:3种方法(/日志console.log/,断点-debugger,排除法)

// 1创建xhr对象
        var xhr=new XMLHttpRequest();
        //2设置xhr对象的事件监听函数
        xhr.onreadystatechange=function(){
            //readyState==4表示服务端的响应结果在客户端已经接收完了
            //status==200表示服务处理请求的过程中没有出现任何异常(响应的都是正常数据)
             if(xhr.readyState==4&&xhr.status==200){
                 //获取span对象
                  var span=document.getElementById("...");
                  //更新span对象内部的内容
                  span.innerHTML=xhr.responseText;
            }
        };        
        //3建立连接(Get请求方式)--与当前网页网址
        xhr.open("GET","http://...",true);
        //4发送请求
        xhr.send(null);
        console.log("===main===") 

xiaowei
1 声望1 粉丝

引用和评论

0 条评论