添加maven依赖

在pom.xml里添加:

<dependency>
    <groupId>io.sentry</groupId>
    <artifactId>sentry-spring-boot-starter</artifactId>
    <version>4.0.0</version>
</dependency>

<!--此时添加是为了防止后边报错-->
<dependency>
    <groupId>org.aspectj</groupId >
    <artifactId>aspectjweaver</artifactId >
    <version>1.8.9</version>
</dependency>

添加sentry的dsn地址

src/main/application.properties:

sentry.dsn=http://143f0c822e844bd7815273caa25446ab@ip:port/4

或者在src/main/application.yml:

sentry:
  dsn:http://143f0c822e844bd7815273caa25446ab@ip:port/4

测试效果

package com.x.xx.xxx;


import io.sentry.Sentry;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Hello {

    @RequestMapping("/index")
    public String index(){
        try {
            throw new Exception("This is a test.");
        } catch (Exception e) {
            Sentry.captureException(e);
        }
        return "Test";
    }
}

相关文章:

  • 2021-12-20
  • 2021-04-18
  • 2021-10-02
  • 2021-12-12
  • 2022-01-30
  • 2021-12-04
  • 2021-12-22
  • 2022-02-18
猜你喜欢
  • 2021-12-25
  • 2021-11-11
  • 2021-07-24
  • 2021-08-29
  • 2022-01-05
  • 2022-12-23
  • 2021-10-22
相关资源
相似解决方案