ko-time/docs/getstart.md
2021-04-27 22:14:07 +08:00

1.8 KiB
Raw Blame History

引入依赖

在pom.xml文件中引入

 <dependency>
    <groupId>cn.langpy</groupId>
    <artifactId>ko-time</artifactId>
    <version>1.8</version>
  </dependency>
  
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-${freemarker或者thymeleaf任选一个}</artifactId>
</dependency>

配置

application.properties文件中进行配置

  • 必填配置

spring.profiles.active=koTime # 如果项目中还有其他配置请用英文逗号分隔koTime,dev
koTime.pointcut=execution(* com.huoyo..*(..)) 需要监测的切面范围参考aop的@pointcut v1.4开始加入的功能

  • 可选配置

koTime.log.enable=false # 是否开启控制输出默认false
koTime.log.language=chinese # 控制台输出语言english/chinese默认chinese
koTime.time.threshold=800.0 # 时间阈值用于前端展示大于阈值显示红色小于阈值显示绿色默认800
koTime.ui.template=thymeleaf # 前端页面模板默认为freemarker可选thymeleaf 与引入的pom依赖对应
koTime.exception.enable=true # 是否开启异常检测默认为false,开启后会对方法内部抛出的异常进行统计 v1.9开始支持

访问

注意:
1.引入了上面的依赖和配置以后确认项目中是否有aop相关的包koTime使用了@Aspect注解未引入的自行引入如aspectj或者spring-boot-starter-aop
2.做完前面的步骤koTime的集成已经完毕无需进行其他配置

  • 启动项目访问 /koTime 路径即可

如果项目自定义的contextpath访问如http://localhost:8080/xxx服务/koTime

application.properties中定义了 server.servlet.context-path=myservice,那么访问路径为http://localhost:8080/myservice/koTime