Minecraft模组开发包冲突:无法导入me.shedaniel.math包求助
Minecraft模组开发依赖包冲突问题
问题描述
- 修改
build.gradle导入依赖时,出现me.shedaniel.math与me.shedaniel.rei包冲突 - 无法正常导入
me.shedaniel.math包,Java及IntelliJ IDEA仅能识别me.shedaniel.rei包 - 尝试复制
.math文件夹被系统阻止,手动新建文件复制类内容工作量极大,难以操作
可行解决方案
1. 调整build.gradle依赖规则
通过排除冲突模块+单独引入目标包的方式解决:
dependencies { // 引入REI时排除自带的math模块 modImplementation "me.shedaniel:RoughlyEnoughItems:${rei_version}" { exclude group: 'me.shedaniel', module: 'math' } // 单独引入需要的math包 implementation "me.shedaniel:math:${math_version}" }
替换${rei_version}和${math_version}为对应依赖的版本号,同步后重新加载Gradle项目。
2. IDE中调整依赖加载顺序
在IntelliJ IDEA中手动设置依赖优先级:
- 打开
File > Project Structure > Modules > Dependencies - 找到包含
me.shedaniel.math的依赖项,拖动到me.shedaniel.rei依赖的上方,让IDE优先加载math包
3. 全类名临时替代导入
如果暂时无法调整依赖,可以在代码中直接使用全类名引用math包的类:
// 无需import,直接用全类名声明 me.shedaniel.math.Rectangle rect = new me.shedaniel.math.Rectangle(0, 0, 100, 100);
内容的提问来源于stack exchange,提问作者Unity
相关产品推荐
相关产品推荐

