使用Maven中的Shade重定位重构import语句 [英] Refactoring import statements using Shade relocations in Maven

查看:396
本文介绍了使用Maven中的Shade重定位重构import语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Shade将依赖项从 com.package.x 重新定位到 com.package.y ;当我使用Maven构建时,由于类型不兼容而引发抱怨 - 所以我必须在我的代码中更改我的import语句以匹配 com.package.y

I've been using Shade to relocate a dependency from com.package.x to com.package.y; when I build with Maven, it complains due to incompatible types - so I have to change my import statements inside my code to match com.package.y.

这真的是解决这个问题的唯一方法吗?更改导入使IntelliJ抱怨并基本上破坏了IDE集成。是否Shade无法修改导入?

Is this really the only way to go about this? Changing the imports is making IntelliJ complain and basically breaks IDE integration. Is there no way Shade can modify the imports?

推荐答案

shade插件的主要用例是生成超级jar同时重新定位其中的一些包以防止冲突。作为一项规则,你不希望针对一个uberjar开发。

The main use case of the shade plugin is to generate an uber-jar while relocating some packages inside of it to prevent conflicts. As a rule you don't want to be developing against an uberjar.

如果你真的想要对着你的阴影罐开发(或者你只是使用阴影来重新定位一个现有的jar),然后你需要列出你的阴影罐代替原来的jar,我想你可能需要你清理循环依赖。

If you actually do want to develop against your shaded jar (or you're solely using shade to relocate an existing jar), then you'll need to list your shaded jar as a in lieu of the original jar, which I would imagine may need you to clean up a cyclic dependency.

这篇关于使用Maven中的Shade重定位重构import语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆