You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决模块中org.intellij.lang.annotations相关类重复冲突问题?

解决JetBrains/IntelliJ注解依赖冲突问题

问题出在哪

你碰到的冲突是因为项目里同时引入了两个同功能但不同groupId的注解库:com.intellij:annotations:12.0 和 org.jetbrains:annotations:13.0。之前的配置只排除了org.jetbrains的那一个,没处理com.intellij的,而且新版Gradle里compile已经被implementation替代,旧的排除规则自然没生效。

几个靠谱的解决办法

1. 全局排除+手动指定统一版本

先把两个冲突的库全排除,再手动添加你需要的统一版本,确保依赖树里只有一份注解库:

configurations.all {
    exclude group: 'com.intellij', module: 'annotations'
    exclude group: 'org.jetbrains', module: 'annotations'
}

dependencies {
    implementation 'org.jetbrains:annotations:13.0'
}

2. 强制Gradle使用指定版本

直接让Gradle强制使用你选定的版本,自动覆盖所有依赖树中的旧版本,无需手动排除:

configurations.all {
    resolutionStrategy.force 'org.jetbrains:annotations:13.0'
}

3. 精准定位冲突来源再排除

要是不确定哪个依赖引入了旧版本的注解库,先执行命令查看完整依赖树:

./gradlew dependencies

找到引入com.intellij:annotations:12.0的具体依赖,然后在该依赖下针对性排除:

dependencies {
    implementation('引入冲突的依赖坐标') {
        exclude group: 'com.intellij', module: 'annotations'
    }
}

验证是否解决

执行以下命令查看implementation配置下的依赖情况,确认输出中只有你指定的注解库版本即可:

./gradlew dependencies --configuration implementation

内容的提问来源于stack exchange,提问作者Salim Karşanbaş

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 15:52:22