简体   繁体   English

Eclipse M2E /更改订单和导出

[英]Eclipse M2E / change Order and Export

I'm working with maven projects in Eclipse (Indigo). 我正在使用Eclipse(Indigo)中的Maven项目。

In order to compile some classes that need endorsed libraries (webservices-api.jar) I go to "Properties/Java Build Path/Order and Export" and move "Maven Dependecies" before "JRE System Library". 为了编译一些需要认可库的类(webservices-api.jar),我转到“属性/ Java构建路径/命令和导出”,并将“ Maven Dependecies”移到“ JRE System Library”之前。

The problem is that whenever I click on the "Maven/Update Project configuration" option the entries are rearranged and "JRE System Library" is always the first entry, and the code no longer compiles. 问题是,每当我单击“ Maven /更新项目配置”选项时,条目都会重新排列,并且“ JRE系统库”始终是第一个条目,并且代码不再编译。

Is there a way to have M2E remember my choice and stop rearranging the libraries? 有没有办法让M2E记住我的选择并停止重新排列库?

Thanks in advance 提前致谢

I understand the webservices-api.jar overrides some classes in standard JRE, right? 我了解webservices-api.jar会覆盖标准JRE中的某些类,对吗?

The only way out I see is moving the jar to JRE\\lib\\ext and mark this dependency in Maven as system . 我看到的唯一出路是将jar移到JRE\\lib\\ext并将Maven中的此依赖项标记为system It's not a good solution, as Maven will stop packing this artifact into your target and it will be your responsibility to handle it. 这不是一个好的解决方案,因为Maven会停止将此工件打包到目标中,而您将有责任对其进行处理。 This has a chance to work — but please note I haven't tried it, so I'm not sure if you manage to override your JRE libs correctly. 这有机会工作-但请注意,我还没有尝试过,所以我不确定您是否能够正确覆盖JRE库。

As for m2e, it takes over control over your Eclipse project settings, so manual tweaking is good as long as you don't update configuration. 至于m2e,它接管了您对Eclipse项目设置的控制,因此,只要不更新配置,手动调整就可以了。

The solution I ended up implementing is having an ant target do a replacement in the .classpath file to swap the classpath containers. 我最终实现的解决方案是让ant目标在.classpath文件中进行替换以交换类路径容器。 I add an ant builder to my project that calls that target and then refresh the project before the java compiler. 我将一个蚂蚁生成器添加到我的项目中,该项目调用该目标,然后在Java编译器之前刷新该项目。 A little complex, but it works like a charm. 有点复杂,但它就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM