Java项目集成Sentry后无法在仪表盘查看问题求助
问题:Sentry无法捕获项目问题,控制台提示源上传不支持
已在主pom.xml中配置Sentry依赖及插件,将Sentry应用URL和访问令牌写入properties文件,项目构建成功,但Sentry仪表盘无法查看问题详情,控制台输出如下警告:
WARN 2024-03-25 11:43:09.152728153 +05:30 Source uploads are not supported by the configured Sentry server
当前配置信息
主pom.xml配置
<dependency> <groupId>io.sentry</groupId> <artifactId>sentry-maven-plugin</artifactId> <version>0.0.7</version> </dependency> <dependency> <groupId>io.sentry</groupId> <artifactId>sentry-spring-boot-starter</artifactId> <version>4.3.0</version> </dependency> <plugin> <groupId>io.sentry</groupId> <artifactId>sentry-maven-plugin</artifactId> <version>0.0.7</version> <extensions>true</extensions> <configuration> <debugSentryCli>true</debugSentryCli> <skip>false</skip> <skipSourceBundle>false</skipSourceBundle> <skipAutoInstall>false</skipAutoInstall> <dsn>http://dns-url</dsn> <org>your_organization_slug</org> <authToken>your_auth_token</authToken> <!-- Configure includes and excludes to scan all files --> <includes> <include>**/*.java</include> </includes> <!-- Optionally, you can exclude specific files or directories --> <!-- <excludes> <exclude>path/to/exclude</exclude> </excludes> --> </configuration> <executions> <execution> <goals> <goal>uploadSourceBundle</goal> </goals> </execution> </executions> </plugin>
sentry.properties配置
# Sentry DSN (replace with your actual DSN) dsn=http://dns-url # Sentry Auth Token (replace with your actual auth token) authToken=your_auth_token # Sentry Organization Slug (replace with your organization's slug) org=your_organization_slug
解决方案
1. 移除不必要的依赖
sentry-maven-plugin是构建插件,无需作为项目依赖引入,删除以下依赖块:
<dependency> <groupId>io.sentry</groupId> <artifactId>sentry-maven-plugin</artifactId> <version>0.0.7</version> </dependency>
2. 升级插件版本
当前插件版本0.0.7与spring-boot-starter的4.3.0版本严重不兼容,将插件版本同步为4.3.0:
<plugin> <groupId>io.sentry</groupId> <artifactId>sentry-maven-plugin</artifactId> <version>4.3.0</version> <!-- 其余配置保留 --> </plugin>
3. 修正DSN配置
注意配置中的dsn是Sentry项目的DSN地址(非DNS),确保填写的是Sentry项目设置中复制的正确地址(格式类似https://xxx@xxx.ingest.sentry.io/xxx),同时保持pom.xml和sentry.properties中的DSN一致。
4. 处理源上传不支持问题
- 若使用自托管Sentry,检查服务器版本,确保版本支持源上传功能(建议升级至最新稳定版)。
- 若不需要源上传,可在插件配置中设置
skipSourceBundle=true,跳过源文件上传步骤:
<configuration> <skipSourceBundle>true</skipSourceBundle> <!-- 其余配置保留 --> </configuration>
5. 验证Auth Token权限
确保使用的Auth Token拥有project:write权限,可在Sentry组织设置中生成具备对应权限的令牌。
6. 测试错误捕获
在项目中主动触发一个异常(例如在Controller中添加接口抛出RuntimeException),启动项目后访问该接口,验证Sentry是否能捕获到异常。
内容的提问来源于stack exchange,提问作者hari krishna
相关产品推荐
相关产品推荐

