m2eclipse:Maven 依赖项作为 JAR 而非项目
我正在 Eclipse 上使用 m2eclipse 插件创建 Maven 项目。该项目有一些依赖项。其中一些是 slf4j、apache-commons 等库。但也有我的库,我正在 eclipse 中同时开发。不幸的是,m2eclipse 创建构建路径的方式是,我的库不是作为来自 M2 存储库的 JAR 存档,而是作为来自 /target/classes
目录的类文件添加到类路径中。因此,我无法使用 maven-shade-plugin,因为我收到一条消息:
“ 创建着色 jar 时出错:打开 zip 文件 /home/user/workspace/my-project/project-a/target 时出错/类
”。
当我使用 mvn clean install
从命令行构建 project-a
时,一切正常 - 生成了阴影 JAR。如何修复它?
I'm having maven project on Eclipse with m2eclipse plugin. This project has some dependencies. Some of them are libraries as slf4j, apache-commons etc. But there are also mine libraries, that I'm developing simultaneously in eclipse. Unfortunately m2eclipse creates build path in such a way that my libraries are added to the classpath not as a JAR archives from M2 repository but as class files from /target/classes
directory. For that reason I can not use maven-shade-plugin beacuse I'm gettin a message:
" Error creating shaded jar: error in opening zip file /home/user/workspace/my-project/project-a/target/classes
".
When I'm building project-a
from command line using mvn clean install
everything works well - shaded JAR is generated. How to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几个小时的搜索,我已经找到了解决方案。这可以通过配置 Maven 构建配置来完成
1. 选择“运行为...”按钮上的箭头
2. 选择运行配置...
3.选择你的项目Maven Builder
4. 在右侧选项卡(主选项卡)上取消选择:解决工作区工件。
单击“应用”并构建您的项目 - 一切都会如您所愿:)。
After few hours of searching I've already found solution. This can be made by configurinng Maven Build Configuration
1. Select arrow on Run as.. button
2. Select Run configurations...
3. Select yours project Maven Builder
4. On the right tab (Main tab) deselect: Resolve Workspace artifacts.
Click Apply and build your project - all will work as you wish :).